]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/fail_compilation/disable.d
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / disable.d
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/disable.d(50): Error: function disable.DisabledOpAssign.opAssign is not callable because it is annotated with @disable
5 fail_compilation/disable.d(53): Error: function disable.DisabledPostblit.opAssign is not callable because it is annotated with @disable
6 fail_compilation/disable.d(56): Error: function disable.HasDtor.opAssign is not callable because it is annotated with @disable
7 fail_compilation/disable.d(60): Error: generated function disable.Nested!(DisabledOpAssign).Nested.opAssign is not callable because it is annotated with @disable
8 fail_compilation/disable.d(63): Error: generated function disable.Nested!(DisabledPostblit).Nested.opAssign is not callable because it is annotated with @disable
9 fail_compilation/disable.d(66): Error: generated function disable.Nested!(HasDtor).Nested.opAssign is not callable because it is annotated with @disable
10 fail_compilation/disable.d(70): Error: generated function disable.NestedDtor!(DisabledOpAssign).NestedDtor.opAssign is not callable because it is annotated with @disable
11 fail_compilation/disable.d(73): Error: generated function disable.NestedDtor!(DisabledPostblit).NestedDtor.opAssign is not callable because it is annotated with @disable
12 fail_compilation/disable.d(76): Error: generated function disable.NestedDtor!(HasDtor).NestedDtor.opAssign is not callable because it is annotated with @disable
13 ---
14 */
15 struct DisabledOpAssign {
16 int x;
17 @disable void opAssign(const DisabledOpAssign);
18 }
19
20 struct DisabledPostblit {
21 int x;
22 @disable void opAssign(const DisabledPostblit);
23 // Doesn't require opAssign
24 @disable this(this);
25 }
26
27 struct HasDtor {
28 int x;
29 @disable void opAssign(const HasDtor);
30 ~this() {} // Makes opAssign mandatory
31 }
32
33
34 struct Nested (T)
35 {
36 T b;
37 }
38
39 struct NestedDtor (T)
40 {
41 T b;
42
43 // Requires an identity opAssign
44 ~this() {}
45 }
46
47 void main ()
48 {
49 DisabledOpAssign o;
50 o = DisabledOpAssign();
51
52 DisabledPostblit p;
53 p = DisabledPostblit();
54
55 HasDtor d;
56 d = HasDtor();
57
58
59 Nested!(DisabledOpAssign) no;
60 no = Nested!(DisabledOpAssign)();
61
62 Nested!(DisabledPostblit) np;
63 np = Nested!(DisabledPostblit)();
64
65 Nested!(HasDtor) nd;
66 nd = Nested!(HasDtor)();
67
68
69 NestedDtor!(DisabledOpAssign) ndo;
70 ndo = NestedDtor!(DisabledOpAssign)();
71
72 NestedDtor!(DisabledPostblit) ndp;
73 ndp = NestedDtor!(DisabledPostblit)();
74
75 NestedDtor!(HasDtor) ndd;
76 ndd = NestedDtor!(HasDtor)();
77 }