Skip to content

Commit

Permalink
Merge pull request #4467 from 9rnsr/fix12799
Browse files Browse the repository at this point in the history
Issue 12799 - Forward reference to nested enum with struct.sizeof
  • Loading branch information
WalterBright committed Mar 25, 2015
2 parents 6577ce7 + 945b754 commit 0358a7d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/struct.c
Expand Up @@ -355,6 +355,13 @@ unsigned AggregateDeclaration::size(Loc loc)
VarDeclaration *v = s->isVarDeclaration();
if (v)
{
/* Bugzilla 12799: enum a = ...; is a VarDeclaration and
* STCmanifest is already set in parssing stage. So we can
* check this before the semantic() call.
*/
if (v->storage_class & STCmanifest)
return 0;

if (v->scope)
v->semantic(NULL);
if (v->storage_class & (STCstatic | STCextern | STCtls | STCgshared | STCmanifest | STCctfe | STCtemplateparameter))
Expand Down
10 changes: 10 additions & 0 deletions test/compilable/compile1.d
Expand Up @@ -709,6 +709,16 @@ final class C12703
S12703 s = S12703(1);
}

/***************************************************/
// 12799

struct A12799
{
int a;
enum C = A12799.sizeof;
enum D = C; // OK <- Error
}

/***************************************************/
// 13236

Expand Down

0 comments on commit 0358a7d

Please sign in to comment.