Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix Issue 9263 - statement is not reachable when statement is reachable

  • Loading branch information...
commit 9e58954f0303064d4aa413011085ce838d00f993 1 parent f11f62e
k-hara authored

Showing 2 changed files with 19 additions and 1 deletion. Show diff stats Hide diff stats

  1. +3 1 src/statement.c
  2. +16 0 test/runnable/testswitch.d
4 src/statement.c
@@ -3321,8 +3321,10 @@ Statement *SwitchStatement::semantic(Scope *sc)
3321 3321
3322 3322 a->reserve(2);
3323 3323 sc->sw->sdefault = new DefaultStatement(loc, s);
3324   - a->push(sc->sw->sdefault);
3325 3324 a->push(body);
  3325 + if (body->blockExit(FALSE) & BEfallthru)
  3326 + a->push(new BreakStatement(0, NULL));
  3327 + a->push(sc->sw->sdefault);
3326 3328 cs = new CompoundStatement(loc, a);
3327 3329 body = cs;
3328 3330 }
16 test/runnable/testswitch.d
@@ -499,6 +499,21 @@ void test7358()
499 499 }
500 500
501 501 /*****************************************/
  502 +// 9263
  503 +
  504 +void test9263()
  505 +{
  506 + enum Foo { A }
  507 +
  508 + Foo f;
  509 + final switch (f) with(Foo)
  510 + {
  511 + case A:
  512 + return;
  513 + }
  514 +}
  515 +
  516 +/*****************************************/
502 517
503 518 int main()
504 519 {
@@ -522,6 +537,7 @@ int main()
522 537 test19();
523 538 test20();
524 539 test7358();
  540 + test9263();
525 541
526 542 printf("Success\n");
527 543 return 0;

0 comments on commit 9e58954

Please sign in to comment.
Something went wrong with that request. Please try again.