Skip to content

Commit

Permalink
Merge pull request #3496 from AndrejMitrovic/Fix12640
Browse files Browse the repository at this point in the history
Issue 12640 - Avoid fallthrough diagnostics when the last case/default statement failed.
  • Loading branch information
yebblies committed Apr 25, 2014
2 parents 3a50fa4 + 567f589 commit c5ebee1
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 c5ebee1

Please sign in to comment.