-
-
Notifications
You must be signed in to change notification settings - Fork 606
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 #562 from 9rnsr/fix6534
Issue 6534 & 7065 & 7172 - Parser improvements for inner aggregates
- Loading branch information
Showing
5 changed files
with
159 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
void main() | ||
{ | ||
class MC{ int x; } | ||
const class CC{ int x; } static assert(is(typeof( CC.x) == const)); | ||
immutable class IC{ int x; } static assert(is(typeof( IC.x) == immutable)); | ||
shared class SC{ int x; } static assert(is(typeof( SC.x) == shared)); | ||
shared const class SCC{ int x; } static assert(is(typeof(SCC.x) == shared) && is(typeof(SCC.x) == const)); | ||
|
||
struct MS{ int x; } | ||
const struct CS{ int x; } static assert(is(typeof( CS.x) == const)); | ||
immutable struct IS{ int x; } static assert(is(typeof( IS.x) == immutable)); | ||
shared struct SS{ int x; } static assert(is(typeof( SS.x) == shared)); | ||
shared const struct SCS{ int x; } static assert(is(typeof(SCS.x) == shared) && is(typeof(SCS.x) == const)); | ||
|
||
union MU{ int x; } | ||
const union CU{ int x; } static assert(is(typeof( CU.x) == const)); | ||
immutable union IU{ int x; } static assert(is(typeof( IU.x) == immutable)); | ||
shared union SU{ int x; } static assert(is(typeof( SU.x) == shared)); | ||
shared const union SCU{ int x; } static assert(is(typeof(SCU.x) == shared) && is(typeof(SCU.x) == const)); | ||
|
||
|
||
static class S_MC{ int x; } | ||
const static class S_CC{ int x; } static assert(is(typeof( S_CC.x) == const)); | ||
immutable static class S_IC{ int x; } static assert(is(typeof( S_IC.x) == immutable)); | ||
shared static class S_SC{ int x; } static assert(is(typeof( S_SC.x) == shared)); | ||
shared const static class S_SCC{ int x; } static assert(is(typeof(S_SCC.x) == shared) && is(typeof(S_SCC.x) == const)); | ||
|
||
static struct S_MS{ int x; } | ||
const static struct S_CS{ int x; } static assert(is(typeof( S_CS.x) == const)); | ||
immutable static struct S_IS{ int x; } static assert(is(typeof( S_IS.x) == immutable)); | ||
shared static struct S_SS{ int x; } static assert(is(typeof( S_SS.x) == shared)); | ||
shared const static struct S_SCS{ int x; } static assert(is(typeof(S_SCS.x) == shared) && is(typeof(S_SCS.x) == const)); | ||
|
||
static union S_MU{ int x; } | ||
const static union S_CU{ int x; } static assert(is(typeof( S_CU.x) == const)); | ||
immutable static union S_IU{ int x; } static assert(is(typeof( S_IU.x) == immutable)); | ||
shared static union S_SU{ int x; } static assert(is(typeof( S_SU.x) == shared)); | ||
shared const static union S_SCU{ int x; } static assert(is(typeof(S_SCU.x) == shared) && is(typeof(S_SCU.x) == const)); | ||
} |
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,38 @@ | ||
void main() | ||
{ | ||
align(1) | ||
struct X1 { ubyte b; int n; } | ||
static assert(X1.sizeof == 8); | ||
static assert(X1.b.offsetof == 0); | ||
static assert(X1.n.offsetof == 4); | ||
//X1 x1; | ||
//assert(cast(void*)&x1.b == cast(void*)&x1 + 0); | ||
//assert(cast(void*)&x1.n == cast(void*)&x1 + 1); | ||
|
||
struct Y1 { ubyte b; int n; } | ||
static assert(Y1.sizeof == 8); | ||
static assert(Y1.b.offsetof == 0); | ||
static assert(Y1.n.offsetof == 4); | ||
//Y1 y1; | ||
//assert(cast(void*)&y1.b == cast(void*)&y1 + 0); | ||
//assert(cast(void*)&y1.n == cast(void*)&y1 + 4); | ||
|
||
int local; | ||
|
||
align(1) | ||
struct X2 { ubyte b; int n; int f(){ return local; } } | ||
static assert(X2.sizeof == 8 + (void*).sizeof); | ||
static assert(X2.b.offsetof == 0); | ||
static assert(X2.n.offsetof == 4); | ||
//X2 x2; | ||
//assert(cast(void*)&x2.b == cast(void*)&x2 + 0); | ||
//assert(cast(void*)&x2.n == cast(void*)&x2 + 1); | ||
|
||
struct Y2 { ubyte b; int n; int f(){ return local; } } | ||
static assert(Y2.sizeof == 8 + (void*).sizeof); | ||
static assert(Y2.b.offsetof == 0); | ||
static assert(Y2.n.offsetof == 4); | ||
//Y2 y2; | ||
//assert(cast(void*)&y2.b == cast(void*)&y2 + 0); | ||
//assert(cast(void*)&y2.n == cast(void*)&y2 + 4); | ||
} |
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,23 @@ | ||
void main() | ||
{ | ||
abstract class AbstractC{} | ||
static assert(!__traits(compiles, { new AbstractC(); })); | ||
|
||
final class FinalC{} | ||
static assert(!__traits(compiles, { class D : FinalC{} })); | ||
|
||
scope class ScopeC{} | ||
static assert(!__traits(compiles, { auto sc = new ScopeC(); })); | ||
static assert( __traits(compiles, { scope sc = new ScopeC(); })); | ||
|
||
synchronized class SyncC{ void f(){} } | ||
static assert(SyncC.f.mangleof[$-13..$] == "5SyncC1fMOFZv"); | ||
|
||
@safe class SCx{ void f(){} } | ||
@trusted class SCy{ void f(){} } | ||
@system class SCz{ void f(){} } | ||
|
||
static assert(SCx.f.mangleof[$-12..$] == "3SCx1fMFNfZv"); // Nf: FuncAttrSafe | ||
static assert(SCy.f.mangleof[$-12..$] == "3SCy1fMFNeZv"); // Ne: FuncAttrTrusted | ||
static assert(SCz.f.mangleof[$-10..$] == "3SCz1fMFZv"); // (none) | ||
} |