1 // { dg-do compile { target c++11 } }
2 // { dg-options "-Wdeprecated" }
4 inline int var1 = 4; // { dg-warning "1:inline variables are only available with" "" { target c++14_down } }
5 static inline int var7 = 9; // { dg-warning "8:inline variables are only available with" "" { target c++14_down } }
8 int inline var2; // { dg-warning "7:inline variables are only available with" "" { target c++14_down } }
9 inline const int var6 = 8; // { dg-warning "3:inline variables are only available with" "" { target c++14_down } }
10 static inline double var8 = 2.0; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
11 extern inline char var10; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
15 static constexpr int var3 = 5;
16 static inline int var4 = 6; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
17 static constexpr int var5 = 7;
18 static inline double var9 = 3.0; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
19 static constexpr inline int var11 = 11; // { dg-warning "20:inline variables are only available with" "" { target c++14_down } }
21 const int S::var3; // { dg-warning "redundant redeclaration of" "" { target c++17 } }
22 const int S::var3; // { dg-error "redefinition of" "" { target c++14_down } }
23 extern int foo (int); // { dg-warning "redundant redeclaration of" "" { target c++17 } .-1 }
25 struct T { T () { t = foo (3); } T (int x) { t = foo (x); } int t; };
26 inline int var12 = foo (0); // { dg-warning "1:inline variables are only available with" "" { target c++14_down } }
27 int inline var13 = foo (1); // { dg-warning "5:inline variables are only available with" "" { target c++14_down } }
30 static inline int var14 = foo (2); // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
31 static inline T var15; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
32 static inline T var16 = 4; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
33 static int inline var17 = foo (5); // { dg-warning "14:inline variables are only available with" "" { target c++14_down } }
34 static constexpr double var18 = 4.0;
36 extern inline int var19; // { dg-warning "8:inline variables are only available with" "" { target c++14_down } }
37 extern inline int var20; // { dg-warning "8:inline variables are only available with" "" { target c++14_down } }
38 int &ref19 = var19; // { dg-error "odr-used inline variable 'var19' is not defined" "" { target *-*-* } .-2 }
39 int sz20 = sizeof (var20);
42 static struct A var21; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } .+1 }
43 static inline struct B var22; // { dg-error "has incomplete type" }
44 static inline struct C var23 = {}; // { dg-error "has incomplete type" }
45 }; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } .-1 }
48 static inline int var24; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
49 static inline const int var25; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
50 // { dg-error "uninitialized const" "" { target *-*-* } .-1 }
51 static inline int var26 = 5; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
52 static inline const int var27 = 6; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
53 static inline double var28 = { 4.0 }; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
54 static const inline double var29 = { 5.0 }; // { dg-warning "16:inline variables are only available with" "" { target c++14_down } }
56 int W::var24; // { dg-error "redefinition of" }
57 const int W::var25; // { dg-error "redefinition of" }
58 int W::var26; // { dg-error "redefinition of" }
59 const int W::var27; // { dg-error "redefinition of" }
60 double W::var28; // { dg-error "redefinition of" }
61 double const W::var29; // { dg-error "redefinition of" }
64 inline int var30; // { dg-error "3:'var30' declared as an 'inline' field" }
66 inline typedef int TT; // { dg-error "1:'TT' declared as an 'inline' type" }
68 foo (inline int var31) // { dg-error "6:'var31' declared as an 'inline' parameter" }
70 inline int var32; // { dg-error "3:'inline' specifier invalid for variable 'var32' declared at block scope" }
71 static inline int var33; // { dg-error "10:'inline' specifier invalid for variable 'var33' declared at block scope" }
74 template <typename A, typename B, typename C>
77 static A var34; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } .+1 }
78 static inline B var35; // { dg-error "has incomplete type" }
79 static inline C var36; // { dg-error "has incomplete type" }
80 }; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } .-1 }
85 A *ptr34 = &Y<A, B, C>::var34;
86 B *ptr35 = &Y<A, B, C>::var35;
87 C *ptr36 = &Y<A, B, C>::var36;
91 static inline int var37; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
92 static inline const int var38; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
93 // { dg-error "uninitialized const" "" { target *-*-* } .-1 }
94 static inline int var39 = 5; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
95 static inline const int var40 = 6; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
96 static inline double var41 = { 4.0 }; // { dg-warning "10:inline variables are only available with" "" { target c++14_down } }
97 static const inline double var42 = { 5.0 }; // { dg-warning "16:inline variables are only available with" "" { target c++14_down } }
98 static constexpr int var43 = 5;
99 static constexpr inline int var44 = 5; // { dg-warning "20:inline variables are only available with" "" { target c++14_down } }
102 int Z<N>::var37; // { dg-error "redefinition of" }
104 const int Z<N>::var38; // { dg-error "redefinition of" }
105 const int &ref38 = Z<0>::var38;
107 int Z<N>::var39; // { dg-error "redefinition of" }
109 const int Z<N>::var40; // { dg-error "redefinition of" }
111 double Z<N>::var41; // { dg-error "redefinition of" }
113 double const Z<N>::var42; // { dg-error "redefinition of" }
115 const int Z<N>::var43; // { dg-warning "redundant redeclaration of" "" { target c++17 } }
116 template <int N> // { dg-warning "redundant redeclaration of" "" { target c++17 } .+1 }
117 const int Z<N>::var43; // { dg-error "redefinition of" "" { target c++14_down } }