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 7 inline int inlvarvariable1 = 1; // { dg-warning "inline variables are only available with" "" { target c++14_down } } 8 const inline int inlvarvariable2 = 2; // { dg-warning "inline variables are only available with" "" { target c++14_down } } 9 namespace N 10 { 11 int inline inlvarvariable3; // { dg-warning "inline variables are only available with" "" { target c++14_down } } 12 const int inline inlvarvariable4 = 4; // { dg-warning "inline variables are only available with" "" { target c++14_down } } 13 } 14 struct S 15 { 16 static inline double inlvarvariable5 = 5.0; // { dg-warning "inline variables are only available with" "" { target c++14_down } } 17 #if __cplusplus >= 201103L 18 static constexpr int inlvarvariable6 = 6; 19 static inline constexpr int inlvarvariable7 = 7; // { dg-warning "inline variables are only available with" "" { target { c++11 && c++14_down } } } 20 #endif 21 }; 22 template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 } 23 inline int inlvarvariable8; // { dg-warning "inline variables are only available with" "" { target c++14_down } } 24 template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 } 25 const int inline inlvarvariable9 = 9; // { dg-warning "inline variables are only available with" "" { target c++14_down } } 26 namespace N 27 { 28 template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 } 29 int inline inlvarvariable10 = 10; // { dg-warning "inline variables are only available with" "" { target c++14_down } } 30 template <int N> // { dg-warning "variable templates only available with" "" { target c++11_down } .+1 } 31 const inline double inlvarvariable11 = 11.0; // { dg-warning "inline variables are only available with" "" { target c++14_down } } 32 } 33 template <int N> 34 struct T 35 { 36 static inline int inlvarvariable12 = 12; // { dg-warning "inline variables are only available with" "" { target c++14_down } } 37 #if __cplusplus >= 201103L 38 static constexpr int inlvarvariable13 = 13; 39 static inline constexpr double inlvarvariable14 = 14.0; // { dg-warning "inline variables are only available with" "" { target { c++11 && c++14_down } } } 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 59