Skip to content

Commit

Permalink
fix Issue 15961 - ICE with instance field introduced by anonymous struct
Browse files Browse the repository at this point in the history
`AnonDeclaration.setFieldOffset` may be called before the `semantic` to determine aggregate instance size in early steps.
  • Loading branch information
9rnsr committed Apr 27, 2016
1 parent 82c5682 commit 4b667bb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/attrib.d
Expand Up @@ -661,6 +661,12 @@ public:
return new AnonDeclaration(loc, isunion, Dsymbol.arraySyntaxCopy(decl));
}

override void setScope(Scope* sc)
{
super.setScope(sc);
alignment = sc.structalign;
}

override void semantic(Scope* sc)
{
//printf("\tAnonDeclaration::semantic %s %p\n", isunion ? "union" : "struct", this);
Expand Down
21 changes: 21 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -7778,6 +7778,27 @@ void test15638()
static assert(is(typeof(arr3) == immutable(A)[]));
}

/***************************************************/
// 15961

struct SliceOverIndexed15961(T)
{
enum assignableIndex = T.init;
}

struct Grapheme15961
{
SliceOverIndexed15961!Grapheme15961 opSlice()
{
assert(0);
}

struct
{
ubyte* ptr_;
}
}

/***************************************************/

int main()
Expand Down

0 comments on commit 4b667bb

Please sign in to comment.