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