OSDN Git Service

2012-12-15 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / implicit12.C
1 // PR c++/50500
2 // { dg-options "-std=c++0x" }
3
4 // If a class declares move operations, the implicitly declared copy
5 // operations are deleted.
6 struct A
7 {
8   A();
9   A(A&&);
10   A& operator=(A&&);
11 };
12
13 // But they can still be explicitly defaulted.
14 struct B
15 {
16   B();
17   B(B&&);
18   B(const B&) = default;
19   B& operator=(B&&);
20   B& operator=(const B&) = default;
21 };
22
23 struct C
24 {
25   C();
26   C(C&&);
27 };
28
29 struct D
30 {
31   D();
32   D& operator=(D&&);
33 };
34
35 int main()
36 {
37   A a;
38   A a2 (a);                     // { dg-error "deleted" }
39   a2 = a;                       // { dg-error "deleted" }
40
41   B b;
42   B b2 (b);
43   b2 = b;
44
45   C c;
46   C c2(c);                      // { dg-error "deleted" }
47   c2 = c;                       // { dg-error "deleted" }
48
49   D d;
50   D d2(d);                      // { dg-error "deleted" }
51   d2 = d;                       // { dg-error "deleted" }
52 }
53
54 // { dg-prune-output "because" }