Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 9e58954f0303064d4aa413011085ce838d00f993 1 parent f11f62e
@9rnsr 9rnsr authored
Showing with 19 additions and 1 deletion.
  1. +3 −1 src/statement.c
  2. +16 −0 test/runnable/testswitch.d
View
4 src/statement.c
@@ -3321,8 +3321,10 @@ Statement *SwitchStatement::semantic(Scope *sc)
a->reserve(2);
sc->sw->sdefault = new DefaultStatement(loc, s);
- a->push(sc->sw->sdefault);
a->push(body);
+ if (body->blockExit(FALSE) & BEfallthru)
+ a->push(new BreakStatement(0, NULL));
+ a->push(sc->sw->sdefault);
cs = new CompoundStatement(loc, a);
body = cs;
}
View
16 test/runnable/testswitch.d
@@ -499,6 +499,21 @@ void test7358()
}
/*****************************************/
+// 9263
+
+void test9263()
+{
+ enum Foo { A }
+
+ Foo f;
+ final switch (f) with(Foo)
+ {
+ case A:
+ return;
+ }
+}
+
+/*****************************************/
int main()
{
@@ -522,6 +537,7 @@ int main()
test19();
test20();
test7358();
+ test9263();
printf("Success\n");
return 0;
Please sign in to comment.
Something went wrong with that request. Please try again.