Skip to content

Commit

Permalink
Fix Issue 12640 - Avoid fallthrough diagnostics when the last case/de…
Browse files Browse the repository at this point in the history
…fault statement in a switch failed semantic analysis.
  • Loading branch information
AndrejMitrovic committed Apr 25, 2014
1 parent 6642adc commit 567f589
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/statement.c
Expand Up @@ -300,9 +300,9 @@ int Statement::blockExit(FuncDeclaration *func, bool mustNotThrow)
// Allow if last case/default was empty
CaseStatement *sc = slast->isCaseStatement();
DefaultStatement *sd = slast->isDefaultStatement();
if (sc && (!sc->statement->hasCode() || sc->statement->isCaseStatement()))
if (sc && (!sc->statement->hasCode() || sc->statement->isCaseStatement() || sc->statement->isErrorStatement()))
;
else if (sd && (!sd->statement->hasCode() || sd->statement->isCaseStatement()))
else if (sd && (!sd->statement->hasCode() || sd->statement->isCaseStatement() || sd->statement->isErrorStatement()))
;
else
{
Expand Down
30 changes: 30 additions & 0 deletions test/fail_compilation/diag12640.d
@@ -0,0 +1,30 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag12640.d(14): Error: undefined identifier asdf
fail_compilation/diag12640.d(23): Error: undefined identifier asdf
---
*/

void main()
{
switch (1)
{
case 0:
asdf;
break;

default:
}

switch (1)
{
default:
asdf;
break;

case 0:
}

}

0 comments on commit 567f589

Please sign in to comment.