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