| 1 |
// PR c++/42844 |
| 2 |
// { dg-do compile } |
| 3 |
|
| 4 |
struct A |
| 5 |
{ |
| 6 |
A(){} |
| 7 |
}; |
| 8 |
|
| 9 |
struct B : A { int i; }; // { dg-message "user-provided default constructor" } |
| 10 |
|
| 11 |
struct C : A { int i; }; // { dg-message "user-provided default constructor" } |
| 12 |
|
| 13 |
struct D : B { D() {} }; |
| 14 |
|
| 15 |
struct E { int i; }; // { dg-message "user-provided default constructor" } |
| 16 |
|
| 17 |
template <class T> |
| 18 |
struct F : A { T t; }; // { dg-message "user-provided default constructor" } |
| 19 |
|
| 20 |
template <class T> |
| 21 |
struct G { T t; }; // { dg-message "user-provided default constructor" } |
| 22 |
|
| 23 |
void f () |
| 24 |
{ |
| 25 |
B const b; // { dg-error "uninitialized 'const" } |
| 26 |
extern B const bext; |
| 27 |
|
| 28 |
C const c[ 1 ]; // { dg-error "uninitialized 'const" } |
| 29 |
extern C const cext[ 1 ]; |
| 30 |
|
| 31 |
D const d; |
| 32 |
extern D const dext; |
| 33 |
|
| 34 |
E const e; // { dg-error "uninitialized 'const" } |
| 35 |
extern E const eext; |
| 36 |
|
| 37 |
F<int> const f; // { dg-error "uninitialized 'const" } |
| 38 |
extern F<int> const fext; |
| 39 |
|
| 40 |
G<int> const g; // { dg-error "uninitialized 'const" } |
| 41 |
extern G<int> const gext; |
| 42 |
} |
| 43 |
|
| 44 |
struct H { int i; }; // { dg-message "user-provided default constructor" } |
| 45 |
|
| 46 |
struct I : A { int i; }; // { dg-message "user-provided default constructor" } |
| 47 |
|
| 48 |
template <class T> |
| 49 |
void g () |
| 50 |
{ |
| 51 |
T const t; // { dg-error "uninitialized 'const" } |
| 52 |
extern T const text; // { dg-error "conflicting declaration" } |
| 53 |
} |
| 54 |
|
| 55 |
template void g<H> (); |
| 56 |
template void g<I> (); |