Skip to content

Commit

Permalink
fixup pull#2210 - Change error report timing
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jun 19, 2013
1 parent 3527e7d commit 58f0c95
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/statement.c
Expand Up @@ -3906,6 +3906,11 @@ Statement *ReturnStatement::semantic(Scope *sc)

if (exp && tbret->ty == Tvoid && !implicit0)
{
if (exp->type->ty != Tvoid)
{
error("cannot return non-void from void function");
}

/* Replace:
* return exp;
* with:
Expand All @@ -3915,11 +3920,6 @@ Statement *ReturnStatement::semantic(Scope *sc)
Statement *s = new ExpStatement(loc, ce);
s = s->semantic(sc);

if (exp->type->ty != Tvoid)
{
error("cannot return non-void from void function");
}

exp = NULL;
return new CompoundStatement(loc, s, this);
}
Expand Down

0 comments on commit 58f0c95

Please sign in to comment.