From 875a8b25b2544129ff72d9b88aee5105ffc9c18b Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Sat, 28 Mar 2009 21:10:53 +0100 Subject: [PATCH] Fix bug in CaseStatement::semantic when there's no enclosing switch. --- dmd/statement.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dmd/statement.c b/dmd/statement.c index d440ca7e..404f2b41 100644 --- a/dmd/statement.c +++ b/dmd/statement.c @@ -2424,16 +2424,16 @@ Statement *CaseStatement::semantic(Scope *sc) //printf("CaseStatement::semantic() %s\n", toChars()); - // LDC - enclosingScopeExit = sc->enclosingScopeExit; - if (enclosingScopeExit != sw->enclosingScopeExit) - { - error("case must be inside the same try, synchronized or volatile level as switch"); - } - exp = exp->semantic(sc); if (sw) { + // LDC + enclosingScopeExit = sc->enclosingScopeExit; + if (enclosingScopeExit != sw->enclosingScopeExit) + { + error("case must be inside the same try, synchronized or volatile level as switch"); + } + exp = exp->implicitCastTo(sc, sw->condition->type); exp = exp->optimize(WANTvalue | WANTinterpret); if (exp->op != TOKstring && exp->op != TOKint64)