| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/disable.d(56): Error: function `disable.DisabledOpAssign.opAssign` cannot be used because it is annotated with `@disable` |
| 5 |
fail_compilation/disable.d(59): Error: function `disable.DisabledPostblit.opAssign` cannot be used because it is annotated with `@disable` |
| 6 |
fail_compilation/disable.d(62): Error: function `disable.HasDtor.opAssign` cannot be used because it is annotated with `@disable` |
| 7 |
fail_compilation/disable.d(66): Error: generated function `disable.Nested!(DisabledOpAssign).Nested.opAssign` cannot be used because it is annotated with `@disable` |
| 8 |
fail_compilation/disable.d(69): Error: generated function `disable.Nested!(DisabledPostblit).Nested.opAssign` cannot be used because it is annotated with `@disable` |
| 9 |
fail_compilation/disable.d(72): Error: generated function `disable.Nested!(HasDtor).Nested.opAssign` cannot be used because it is annotated with `@disable` |
| 10 |
fail_compilation/disable.d(76): Error: generated function `disable.NestedDtor!(DisabledOpAssign).NestedDtor.opAssign` cannot be used because it is annotated with `@disable` |
| 11 |
fail_compilation/disable.d(79): Error: generated function `disable.NestedDtor!(DisabledPostblit).NestedDtor.opAssign` cannot be used because it is annotated with `@disable` |
| 12 |
fail_compilation/disable.d(82): Error: generated function `disable.NestedDtor!(HasDtor).NestedDtor.opAssign` cannot be used because it is annotated with `@disable` |
| 13 |
fail_compilation/disable.d(84): Error: enum member `disable.Enum1.value` cannot be used because it is annotated with `@disable` |
| 14 |
--- |
| 15 |
*/ |
| 16 |
struct DisabledOpAssign { |
| 17 |
int x; |
| 18 |
@disable void opAssign(const DisabledOpAssign); |
| 19 |
} |
| 20 |
|
| 21 |
struct DisabledPostblit { |
| 22 |
int x; |
| 23 |
@disable void opAssign(const DisabledPostblit); |
| 24 |
// Doesn't require opAssign |
| 25 |
@disable this(this); |
| 26 |
} |
| 27 |
|
| 28 |
struct HasDtor { |
| 29 |
int x; |
| 30 |
@disable void opAssign(const HasDtor); |
| 31 |
~this() {} // Makes opAssign mandatory |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
struct Nested (T) |
| 36 |
{ |
| 37 |
T b; |
| 38 |
} |
| 39 |
|
| 40 |
struct NestedDtor (T) |
| 41 |
{ |
| 42 |
T b; |
| 43 |
|
| 44 |
// Requires an identity opAssign |
| 45 |
~this() {} |
| 46 |
} |
| 47 |
|
| 48 |
enum Enum1 |
| 49 |
{ |
| 50 |
@disable value |
| 51 |
} |
| 52 |
|
| 53 |
void main () |
| 54 |
{ |
| 55 |
DisabledOpAssign o; |
| 56 |
o = DisabledOpAssign(); |
| 57 |
|
| 58 |
DisabledPostblit p; |
| 59 |
p = DisabledPostblit(); |
| 60 |
|
| 61 |
HasDtor d; |
| 62 |
d = HasDtor(); |
| 63 |
|
| 64 |
|
| 65 |
Nested!(DisabledOpAssign) no; |
| 66 |
no = Nested!(DisabledOpAssign)(); |
| 67 |
|
| 68 |
Nested!(DisabledPostblit) np; |
| 69 |
np = Nested!(DisabledPostblit)(); |
| 70 |
|
| 71 |
Nested!(HasDtor) nd; |
| 72 |
nd = Nested!(HasDtor)(); |
| 73 |
|
| 74 |
|
| 75 |
NestedDtor!(DisabledOpAssign) ndo; |
| 76 |
ndo = NestedDtor!(DisabledOpAssign)(); |
| 77 |
|
| 78 |
NestedDtor!(DisabledPostblit) ndp; |
| 79 |
ndp = NestedDtor!(DisabledPostblit)(); |
| 80 |
|
| 81 |
NestedDtor!(HasDtor) ndd; |
| 82 |
ndd = NestedDtor!(HasDtor)(); |
| 83 |
|
| 84 |
auto v1 = Enum1.value; |
| 85 |
} |