1 // PR c++/25811
2 // { dg-do compile }
3 
4 struct A1
5 {
6   int const j; // { dg-message "should be initialized" }
7 };
8 
9 struct A2
10 {
11   int const volatile i; // { dg-message "should be initialized" }
12 };
13 
14 struct A3
15 {
16   int& ref; // { dg-message "should be initialized" }
17 };
18 
19 struct A4
20 {
21   int const& ref; // { dg-message "should be initialized" }
22 };
23 
24 struct A5
25 {
26   int& ref; // { dg-message "should be initialized" }
27   int const i; // { dg-message "should be initialized" }
28 };
29 
30 template <class T> struct S1
31 {
32   T const i; // { dg-message "should be initialized" }
33 };
34 
35 template <class T> struct S2
36 {
37   T const volatile i; // { dg-message "should be initialized" }
38 };
39 
40 template <class T> struct S3
41 {
42   T& ref; // { dg-message "should be initialized" }
43 };
44 
45 template <class T> struct S4
46 {
47   T const i; // { dg-message "should be initialized" }
48   T& ref; // { dg-message "should be initialized" }
49 };
50 
51 struct X
52 {
XX53   X () : c (0), r (c) {}
54   int const c;
55   int const& r;
56 };
57 
58 struct Y11
59 {
60   int const i; // { dg-message "should be initialized" }
61 };
62 
63 struct Y1
64 {
65   Y11 a[1];
66 };
67 
68 struct Y22
69 {
70   int& ref; // { dg-message "should be initialized" }
71 };
72 
73 struct Y2
74 {
75   Y22 a[1];
76 };
77 
78 struct Z1
79 {
80   int const i; // { dg-message "should be initialized" }
81 };
82 
83 struct Z2
84 {
85   int& ref; // { dg-message "should be initialized" }
86 };
87 
88 struct Z3
89 {
90   int const i; // { dg-message "should be initialized" }
91 };
92 
93 struct Z4
94 {
95   int& ref; // { dg-message "should be initialized" }
96 };
97 
98 struct Z5
99 {
100   int i;
101 };
102 
103 struct Z
104 {
105   Z1 z1;
106   Z2 z2;
107   Z3 z3;
108   Z4 z4;
109   Z5 z5;
110 };
111 
112 union U
113 {
114   int const i; // { dg-message "should be initialized" }
115 };
116 
f1()117 void f1 ()
118 {
119   new A1; // { dg-error "uninitialized const member" }
120 }
121 
f2()122 void f2 ()
123 {
124   new A2; // { dg-error "uninitialized const member" }
125 }
126 
f3()127 void f3 ()
128 {
129   new A3; // { dg-error "uninitialized reference member" }
130 }
131 
f4()132 void f4 ()
133 {
134   new A4; // { dg-error "uninitialized reference member" }
135 }
136 
f5()137 void f5 ()
138 {
139   new A5; // { dg-error "uninitialized reference member|uninitialized const member" }
140 }
141 
f6()142 void f6 ()
143 {
144   new S1<int>; // { dg-error "uninitialized const member" }
145 }
146 
f7()147 void f7 ()
148 {
149   new S2<int>; // { dg-error "uninitialized const member" }
150 }
151 
f8()152 void f8 ()
153 {
154   new S3<int>; // { dg-error "uninitialized reference member" }
155 }
156 
f9()157 void f9 ()
158 {
159   new S4<int>; // { dg-error "uninitialized reference member|uninitialized const member" }
160 }
161 
f10()162 void f10 ()
163 {
164   new X;
165 }
166 
f11()167 void f11 ()
168 {
169   new A1[1]; // { dg-error "uninitialized const member" }
170 }
171 
f12()172 void f12 ()
173 {
174   new A3[1]; // { dg-error "uninitialized reference member" }
175 }
176 
f13()177 void f13 ()
178 {
179   new Y1; // { dg-error "uninitialized const member" }
180 }
181 
f14()182 void f14 ()
183 {
184   new Y2; // { dg-error "uninitialized reference member" }
185 }
186 
f15()187 void f15 ()
188 {
189   new Z; // { dg-error "uninitialized reference member|uninitialized const member" }
190 }
191 
f16()192 void f16 ()
193 {
194   new U; // { dg-error "uninitialized const member" }
195 }
196