summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/defaulted2.C
blob: e3aac8f1a9fdb69fffa6a298a7fdab36aa25d099 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
// Negative test for defaulted/deleted fns.
// { dg-options "-std=c++0x" }

void f();			// { dg-error "previous" }
void f() = delete;		// { dg-error "deleted" }

struct A
{
  A() { }			// { dg-error "previous" }
  void f() = default;		// { dg-error "default" }
};

A::A() = default;		// { dg-error "redefinition" }

void g() {}			// { dg-error "previous" }
void g() = delete;		// { dg-error "redefinition" }

struct B // { dg-message "user-provided default constructor" }
{
  int i;
  B() = default;		// { dg-message "not user-provided" }
};

const B b;			// { dg-error "uninitialized const" }

struct C
{
  virtual void f() = delete;	// { dg-error "overriding deleted" }
};

struct D: public C
{
  virtual void f();		// { dg-error "non-deleted function" }
};

struct E
{
  const B b;
  E() { }			// { dg-error "uninitialized" }
};

struct F
{
  F() = default;
  F(const F&) = delete;		// { dg-error "declared" }
};

struct G
{
  G();
};

// ctor defaulted after class defn is not trivial
G::G() = default;

union U
{
  G g;				// { dg-error "union member.*non-trivial" }
};

int main()
{
  F f;
  F f2(f);			// { dg-error "use" }
  B* b = new const B;		// { dg-error "uninitialized const" }
  U u;				// { dg-error "deleted" }
}

// { dg-prune-output "implicitly deleted because" }