Skip to content

Commit

Permalink
fix Issue 9892 - [ICE] forward reference in enum declaration members …
Browse files Browse the repository at this point in the history
…causes compiler segfault
  • Loading branch information
WalterBright committed Apr 6, 2013
1 parent bea22e3 commit edd0a0e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/expression.c
Expand Up @@ -3039,6 +3039,12 @@ Expression *DsymbolExp::semantic(Scope *sc)
if (em)
{
e = em->value;
if (!e)
{
em->errors = true;
error("forward reference of %s %s", s->kind(), s->toChars());
return new ErrorExp();
}
e->loc = loc;
e = e->semantic(sc);
return e;
Expand All @@ -3052,7 +3058,7 @@ Expression *DsymbolExp::semantic(Scope *sc)
v->semantic(v->scope);
type = v->type;
if (!v->type)
{ error("forward reference of %s %s", v->kind(), v->toChars());
{ error("forward reference of %s %s", s->kind(), s->toChars());
return new ErrorExp();
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/fail_compilation/fail9892.d
@@ -0,0 +1,7 @@
// 9892

enum
{
a = b, //Segfault!
b
}

0 comments on commit edd0a0e

Please sign in to comment.