summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/init/pr42844.C
blob: 299a30a91d2f1dc865966f7f2f79c19b0a233ec1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// PR c++/42844
// { dg-do compile }

struct A
{
  A(){}
};

struct B : A { int i; }; // { dg-message "user-provided default constructor" }

struct C : A { int i; }; // { dg-message "user-provided default constructor" }

struct D : B { D() {} };

struct E { int i; }; // { dg-message "user-provided default constructor" }

template <class T>
struct F : A { T t; }; // { dg-message "user-provided default constructor" }

template <class T>
struct G { T t; }; // { dg-message "user-provided default constructor" }

void f ()
{
  B const b;    // { dg-error "uninitialized const" }
  extern B const bext;

  C const c[ 1 ]; // { dg-error "uninitialized const" }
  extern C const cext[ 1 ];

  D const d;
  extern D const dext;

  E const e;	// { dg-error "uninitialized const" }
  extern E const eext;

  F<int> const f; // { dg-error "uninitialized const" }
  extern F<int> const fext;

  G<int> const g; // { dg-error "uninitialized const" }
  extern G<int> const gext;
}

struct H { int i; }; // { dg-message "user-provided default constructor" }

struct I : A { int i; }; // { dg-message "user-provided default constructor" }

template <class T>
void g ()
{
  T const t; // { dg-error "uninitialized const" }
  extern T const text;
}

template void g<H> ();
template void g<I> ();