Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4650 from MartinNowak/aggrDtor
make inclusive dtor/postblit available
- Loading branch information
Showing
10 changed files
with
220 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// PERMUTE_ARGS: | ||
|
||
struct Field | ||
{ | ||
~this() @safe @nogc pure nothrow {} | ||
} | ||
|
||
struct Counter | ||
{ | ||
static size_t cnt; | ||
~this() @safe @nogc nothrow { ++cnt; } | ||
} | ||
|
||
struct Foo | ||
{ | ||
~this() @safe @nogc pure nothrow {} | ||
Field field; | ||
} | ||
|
||
class Bar | ||
{ | ||
~this() @safe @nogc pure nothrow {} | ||
Field field; | ||
} | ||
|
||
void test1() @safe @nogc pure nothrow | ||
{ | ||
Foo foo; | ||
foo.__xdtor(); | ||
scope bar = new Bar(); | ||
bar.__xdtor(); | ||
} | ||
|
||
static assert(__traits(hasMember, Foo, "__xdtor")); | ||
static assert(__traits(hasMember, Bar, "__xdtor")); | ||
|
||
// | ||
|
||
struct FieldDtor | ||
{ | ||
Counter counter; | ||
} | ||
|
||
struct AggrDtor | ||
{ | ||
static size_t cnt; | ||
~this() @safe @nogc nothrow { ++cnt; } | ||
} | ||
|
||
struct MixedDtor | ||
{ | ||
static size_t cnt; | ||
Counter counter; | ||
~this() @safe @nogc nothrow { ++cnt; } | ||
} | ||
|
||
struct SNoDtor {} | ||
class CNoDtor {} | ||
|
||
static assert(!__traits(hasMember, SNoDtor, "__xdtor")); | ||
static assert(!__traits(hasMember, CNoDtor, "__xdtor")); | ||
|
||
void test2() @safe @nogc nothrow | ||
{ | ||
FieldDtor a; | ||
assert(Counter.cnt == 0); | ||
a.__xdtor(); | ||
assert(Counter.cnt == 1); | ||
AggrDtor b; | ||
assert(AggrDtor.cnt == 0); | ||
b.__xdtor(); | ||
assert(AggrDtor.cnt == 1); | ||
Counter.cnt = 0; | ||
MixedDtor c; | ||
assert(MixedDtor.cnt == 0); | ||
assert(Counter.cnt == 0); | ||
c.__xdtor(); | ||
assert(MixedDtor.cnt == 1); | ||
assert(Counter.cnt == 1); | ||
} | ||
|
||
void main() | ||
{ | ||
test1(); | ||
test2(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// PERMUTE_ARGS: | ||
|
||
struct Field | ||
{ | ||
this(this) @safe @nogc pure nothrow {} | ||
} | ||
|
||
struct Counter | ||
{ | ||
static size_t cnt; | ||
this(this) @safe @nogc nothrow { ++cnt; } | ||
} | ||
|
||
struct Foo | ||
{ | ||
this(this) @safe @nogc pure nothrow {} | ||
Field field; | ||
} | ||
|
||
void test1() @safe @nogc pure nothrow | ||
{ | ||
Foo foo; | ||
foo.__xpostblit(); | ||
} | ||
|
||
static assert(__traits(hasMember, Foo, "__xpostblit")); | ||
|
||
// | ||
|
||
struct FieldPostblit | ||
{ | ||
Counter counter; | ||
} | ||
|
||
struct AggrPostblit | ||
{ | ||
static size_t cnt; | ||
this(this) @safe @nogc nothrow { ++cnt; } | ||
} | ||
|
||
struct MixedPostblit | ||
{ | ||
static size_t cnt; | ||
Counter counter; | ||
this(this) @safe @nogc nothrow { ++cnt; } | ||
} | ||
|
||
struct SNoPostblit {} | ||
class CNoPostblit {} | ||
|
||
static assert(!__traits(hasMember, SNoPostblit, "__xpostblit")); | ||
static assert(!__traits(hasMember, CNoPostblit, "__xpostblit")); | ||
|
||
void test2() @safe @nogc nothrow | ||
{ | ||
FieldPostblit a; | ||
assert(Counter.cnt == 0); | ||
a.__xpostblit(); | ||
assert(Counter.cnt == 1); | ||
AggrPostblit b; | ||
assert(AggrPostblit.cnt == 0); | ||
b.__xpostblit(); | ||
assert(AggrPostblit.cnt == 1); | ||
Counter.cnt = 0; | ||
MixedPostblit c; | ||
assert(MixedPostblit.cnt == 0); | ||
assert(Counter.cnt == 0); | ||
c.__xpostblit(); | ||
assert(MixedPostblit.cnt == 1); | ||
assert(Counter.cnt == 1); | ||
} | ||
|
||
void main() | ||
{ | ||
test1(); | ||
test2(); | ||
} |