Merge with main truk.
[official-gcc.git] / gcc / testsuite / g++.dg / init / pr43719.C
blobc8cebc2de1530a5fa77a0dfc6479213f7be31943
1 // PR c++/43719
2 // { dg-do compile }
4 struct A1 // { dg-error "uninitialized" "" { target c++11 } }
6   int const j; // { dg-message "should be initialized" }
7 };
9 struct A2 // { dg-error "uninitialized" "" { target c++11 } }
11   int const volatile i; // { dg-message "should be initialized" }
14 struct A3 // { dg-error "uninitialized" "" { target c++11 } }
16   int& ref; // { dg-message "should be initialized" }
19 struct A4 // { dg-error "uninitialized" "" { target c++11 } }
21   int const& ref; // { dg-message "should be initialized" }
24 struct A5 // { dg-error "uninitialized" "" { target c++11 } }
26   int& ref; // { dg-message "should be initialized" }
27   int const i; // { dg-message "should be initialized" }
30 template <class T> struct S1 // { dg-error "uninitialized" "" { target c++11 } }
32   T const i; // { dg-message "should be initialized" }
35 template <class T> struct S2 // { dg-error "uninitialized" "" { target c++11 } }
37   T const volatile i; // { dg-message "should be initialized" }
40 template <class T> struct S3 // { dg-error "uninitialized" "" { target c++11 } }
42   T& ref; // { dg-message "should be initialized" }
45 template <class T> struct S4 // { dg-error "uninitialized" "" { target c++11 } }
47   T const i; // { dg-message "should be initialized" }
48   T& ref; // { dg-message "should be initialized" }
51 struct X
53   X () : c (0), r (c) {}
54   int const c;
55   int const& r;
58 struct Y11 // { dg-error "uninitialized" "" { target c++11 } }
60   int const i; // { dg-message "should be initialized" }
63 struct Y1                 // { dg-error "deleted" "" { target c++11 } }
65   Y11 a[1];
68 struct Y22 // { dg-error "uninitialized" "" { target c++11 } }
70   int& ref; // { dg-message "should be initialized" }
73 struct Y2                     // { dg-error "deleted" "" { target c++11 } }
75   Y22 a[1];
78 struct Z1 // { dg-error "uninitialized" "" { target c++11 } }
80   int const i; // { dg-message "should be initialized" }
83 struct Z2 // { dg-error "uninitialized" "" { target c++11 } }
85   int& ref; // { dg-message "should be initialized" }
88 struct Z3 // { dg-error "uninitialized" "" { target c++11 } }
90   int const i; // { dg-message "should be initialized" }
93 struct Z4 // { dg-error "uninitialized" "" { target c++11 } }
95   int& ref; // { dg-message "should be initialized" }
98 struct Z5
100   int i;
103 struct Z                // { dg-error "deleted" "" { target c++11 } }
105   Z1 z1;
106   Z2 z2;
107   Z3 z3;
108   Z4 z4;
109   Z5 z5;
112 union U // { dg-error "uninitialized" "" { target c++11 } }
114   int const i; // { dg-message "should be initialized" }
118 void f1 ()
120   A1 a1; // { dg-error "uninitialized const member|deleted" }
123 void f2 ()
125   A2 a2; // { dg-error "uninitialized const member|deleted" }
128 void f3 ()
130   A3 a3; // { dg-error "uninitialized reference member|deleted" }
133 void f4 ()
135   A4 a4; // { dg-error "uninitialized reference member|deleted" }
138 void f5 ()
140   A5 a5; // { dg-error "uninitialized reference member|uninitialized const member|deleted" }
143 void f6 ()
145   S1<int> s; // { dg-error "uninitialized const member|deleted" }
148 void f7 ()
150   S2<int> s; // { dg-error "uninitialized const member|deleted" }
153 void f8 ()
155   S3<int> s; // { dg-error "uninitialized reference member|deleted" }
158 void f9 ()
160   S4<int> s; // { dg-error "uninitialized reference member|uninitialized const member|deleted" }
163 void f10 ()
165   X x;
168 void f11 ()
170   A1 a[ 1 ]; // { dg-error "uninitialized const member|deleted" }
173 void f12 ()
175   A3 a[ 1 ]; // { dg-error "uninitialized reference member|deleted" }
178 void f13 ()
180   Y1 y1; // { dg-error "uninitialized const member|deleted" }
183 void f14 ()
185   Y2 y2; // { dg-error "uninitialized reference member|deleted" }
188 void f15 ()
190   Z z; // { dg-error "uninitialized reference member|uninitialized const member|deleted" }
193 void f16 ()
195   U u; // { dg-error "uninitialized const member|deleted" }