MATCH: Improve `A CMP 0 ? A : -A` set of patterns to use bitwise_equal_p.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / dtorfields_attributes.d
blobf6cab893bb44e222a769954c1804b2a9ad09d26a
1 /*
2 Informative error messages if the compiler inserted an optional destructor call into the constructor.
4 REQUIRED_ARGS: -preview=dtorfields
5 TEST_OUTPUT:
6 ---
7 fail_compilation/dtorfields_attributes.d(117): Error: `pure` constructor `dtorfields_attributes.Strict.this` cannot call impure destructor `dtorfields_attributes.Strict.~this`
8 fail_compilation/dtorfields_attributes.d(119): generated `Strict.~this` is impure because of the following field's destructors:
9 fail_compilation/dtorfields_attributes.d(115): - HasDtor member
10 fail_compilation/dtorfields_attributes.d(103): impure `HasDtor.~this` is declared here
11 fail_compilation/dtorfields_attributes.d(117): Error: `@safe` constructor `dtorfields_attributes.Strict.this` cannot call `@system` destructor `dtorfields_attributes.Strict.~this`
12 fail_compilation/dtorfields_attributes.d(119): `dtorfields_attributes.Strict.~this` is declared here
13 fail_compilation/dtorfields_attributes.d(119): generated `Strict.~this` is @system because of the following field's destructors:
14 fail_compilation/dtorfields_attributes.d(115): - HasDtor member
15 fail_compilation/dtorfields_attributes.d(103): @system `HasDtor.~this` is declared here
16 fail_compilation/dtorfields_attributes.d(117): Error: `@nogc` constructor `dtorfields_attributes.Strict.this` cannot call non-@nogc destructor `dtorfields_attributes.Strict.~this`
17 fail_compilation/dtorfields_attributes.d(119): generated `Strict.~this` is non-@nogc because of the following field's destructors:
18 fail_compilation/dtorfields_attributes.d(115): - HasDtor member
19 fail_compilation/dtorfields_attributes.d(103): non-@nogc `HasDtor.~this` is declared here
20 ---
22 #line 100
24 struct HasDtor
26 ~this()
28 // Enforce @system, ... just to be sure
29 __gshared int i;
30 if (++i)
31 throw new Exception(new immutable(char)[](10));
35 // The user-defined dtor matches the ctor attributes
36 struct Strict
38 HasDtor member;
40 this(int) pure @nogc @safe {} // nothrow doesn't generate dtor call
42 ~this() pure @nogc @safe {}