diff --git a/dmd/statement.c b/dmd/statement.c index 0b01aca6..958a6c7e 100644 --- a/dmd/statement.c +++ b/dmd/statement.c @@ -2334,7 +2334,12 @@ Statement *SwitchStatement::semantic(Scope *sc) a->reserve(4); a->push(body); - a->push(new BreakStatement(loc, NULL)); + + // LDC needs semantic to be run on break + Statement *breakstmt = new BreakStatement(loc, NULL); + breakstmt->semantic(sc); + a->push(breakstmt); + sc->sw->sdefault = new DefaultStatement(loc, s); a->push(sc->sw->sdefault); cs = new CompoundStatement(loc, a); diff --git a/tests/mini/compile_bug174_enclosing_on_break.d b/tests/mini/compile_bug174_enclosing_on_break.d new file mode 100644 index 00000000..8972f310 --- /dev/null +++ b/tests/mini/compile_bug174_enclosing_on_break.d @@ -0,0 +1,5 @@ +void main() +{ + scope Object o; + switch(0) {} +}