111
|
1 // { dg-do compile }
|
|
2 // { dg-options "-g0" }
|
|
3 // Verify that inline variables and static data members that aren't odr-used
|
|
4 // aren't emitted into assembly even at -O0.
|
|
5 // { dg-final { scan-assembler-not "inlvarvariable" } }
|
|
6
|
131
|
7 inline int inlvarvariable1 = 1; // { dg-warning "1:inline variables are only available with" "" { target c++14_down } }
|
|
8 const inline int inlvarvariable2 = 2; // { dg-warning "7:inline variables are only available with" "" { target c++14_down } }
|
111
|
9 namespace N
|
|
10 {
|
131
|
11 int inline inlvarvariable3; // { dg-warning "7:inline variables are only available with" "" { target c++14_down } }
|
|
12 const int inline inlvarvariable4 = 4; // { dg-warning "13:inline variables are only available with" "" { target c++14_down } }
|
111
|
13 }
|
|
14 struct S
|
|
15 {
|
131
|
16 static inline double inlvarvariable5 = 5.0; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
|
111
|
17 #if __cplusplus >= 201103L
|
|
18 static constexpr int inlvarvariable6 = 6;
|
131
|
19 static inline constexpr int inlvarvariable7 = 7; // { dg-warning "10:inline variables are only available with" "" { target { c++11 && c++14_down } } }
|
111
|
20 #endif
|
|
21 };
|
|
22 template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 }
|
131
|
23 inline int inlvarvariable8; // { dg-warning "1:inline variables are only available with" "" { target c++14_down } }
|
111
|
24 template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 }
|
131
|
25 const int inline inlvarvariable9 = 9; // { dg-warning "11:inline variables are only available with" "" { target c++14_down } }
|
111
|
26 namespace N
|
|
27 {
|
|
28 template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 }
|
131
|
29 int inline inlvarvariable10 = 10; // { dg-warning "7:inline variables are only available with" "" { target c++14_down } }
|
111
|
30 template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 }
|
131
|
31 const inline double inlvarvariable11 = 11.0; // { dg-warning "9:inline variables are only available with" "" { target c++14_down } }
|
111
|
32 }
|
|
33 template <int N>
|
|
34 struct T
|
|
35 {
|
131
|
36 static inline int inlvarvariable12 = 12; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
|
111
|
37 #if __cplusplus >= 201103L
|
|
38 static constexpr int inlvarvariable13 = 13;
|
131
|
39 static inline constexpr double inlvarvariable14 = 14.0; // { dg-warning "10:inline variables are only available with" "" { target { c++11 && c++14_down } } }
|
111
|
40 #endif
|
|
41 };
|
|
42 #if __cplusplus < 201103L
|
|
43 #define decltype(x) int
|
|
44 #endif
|
|
45 decltype (inlvarvariable1) v1 = inlvarvariable2 + sizeof (inlvarvariable1);
|
|
46 decltype (N::inlvarvariable3) v2 = N::inlvarvariable4 + sizeof (N::inlvarvariable3);
|
|
47 #if __cplusplus >= 201103L
|
|
48 decltype (S::inlvarvariable6) v3 = sizeof (S::inlvarvariable5) + S::inlvarvariable6 + S::inlvarvariable7;
|
|
49 #else
|
|
50 int v3 = sizeof (S::inlvarvariable5);
|
|
51 #endif
|
|
52 decltype (inlvarvariable8<2>) v4 = inlvarvariable9<2> + sizeof (inlvarvariable8<2>);
|
|
53 decltype (N::inlvarvariable10<0>) v5 = sizeof (N::inlvarvariable10<0>) + sizeof (N::inlvarvariable11<0>);
|
|
54 #if __cplusplus >= 201103L
|
|
55 decltype (T<-1>::inlvarvariable12) v6 = sizeof (T<-1>::inlvarvariable14) + sizeof (T<-1>::inlvarvariable12) + T<-1>::inlvarvariable13;
|
|
56 #else
|
|
57 int v6 = sizeof (T<-1>::inlvarvariable12);
|
|
58 #endif
|