comparison dmd/statement.c @ 1164:166042b48c28

Fix bug in CaseStatement::semantic when there's no enclosing switch.
author Christian Kamm <kamm incasoftware de>
date Sat, 28 Mar 2009 21:10:53 +0100
parents c6d6a68bb5db
children e961851fb8be
comparison
equal deleted inserted replaced
1163:ea52660f828b 1164:166042b48c28
2422 Statement *CaseStatement::semantic(Scope *sc) 2422 Statement *CaseStatement::semantic(Scope *sc)
2423 { SwitchStatement *sw = sc->sw; 2423 { SwitchStatement *sw = sc->sw;
2424 2424
2425 //printf("CaseStatement::semantic() %s\n", toChars()); 2425 //printf("CaseStatement::semantic() %s\n", toChars());
2426 2426
2427 // LDC
2428 enclosingScopeExit = sc->enclosingScopeExit;
2429 if (enclosingScopeExit != sw->enclosingScopeExit)
2430 {
2431 error("case must be inside the same try, synchronized or volatile level as switch");
2432 }
2433
2434 exp = exp->semantic(sc); 2427 exp = exp->semantic(sc);
2435 if (sw) 2428 if (sw)
2436 { 2429 {
2430 // LDC
2431 enclosingScopeExit = sc->enclosingScopeExit;
2432 if (enclosingScopeExit != sw->enclosingScopeExit)
2433 {
2434 error("case must be inside the same try, synchronized or volatile level as switch");
2435 }
2436
2437 exp = exp->implicitCastTo(sc, sw->condition->type); 2437 exp = exp->implicitCastTo(sc, sw->condition->type);
2438 exp = exp->optimize(WANTvalue | WANTinterpret); 2438 exp = exp->optimize(WANTvalue | WANTinterpret);
2439 if (exp->op != TOKstring && exp->op != TOKint64) 2439 if (exp->op != TOKstring && exp->op != TOKint64)
2440 { 2440 {
2441 error("case must be a string or an integral constant, not %s", exp->toChars()); 2441 error("case must be a string or an integral constant, not %s", exp->toChars());