"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/dmd/statementsem.d" between
dmd-2.094.0.tar.gz and dmd-2.094.1.tar.gz

About: DMD (Digital Mars D) is the D reference compiler. D is an object-oriented, imperative, multi-paradigm system programming language.

statementsem.d  (dmd-2.094.0):statementsem.d  (dmd-2.094.1)
skipping to change at line 2778 skipping to change at line 2778
bool errors = false; bool errors = false;
//printf("CaseStatement::semantic() %s\n", toChars()); //printf("CaseStatement::semantic() %s\n", toChars());
sc = sc.startCTFE(); sc = sc.startCTFE();
cs.exp = cs.exp.expressionSemantic(sc); cs.exp = cs.exp.expressionSemantic(sc);
cs.exp = resolveProperties(sc, cs.exp); cs.exp = resolveProperties(sc, cs.exp);
sc = sc.endCTFE(); sc = sc.endCTFE();
if (sw) if (sw)
{ {
Expression initialExp = cs.exp;
cs.exp = cs.exp.implicitCastTo(sc, sw.condition.type); cs.exp = cs.exp.implicitCastTo(sc, sw.condition.type);
cs.exp = cs.exp.optimize(WANTvalue | WANTexpand); cs.exp = cs.exp.optimize(WANTvalue | WANTexpand);
Expression e = cs.exp; Expression e = cs.exp;
// Remove all the casts the user and/or implicitCastTo may introduce // Remove all the casts the user and/or implicitCastTo may introduce
// otherwise we'd sometimes fail the check below. // otherwise we'd sometimes fail the check below.
while (e.op == TOK.cast_) while (e.op == TOK.cast_)
e = (cast(CastExp)e).e1; e = (cast(CastExp)e).e1;
/* This is where variables are allowed as case expressions. /* This is where variables are allowed as case expressions.
skipping to change at line 2851 skipping to change at line 2853
cs.error("`case` must be a `string` or an integral constant, not `%s`", cs.exp.toChars()); cs.error("`case` must be a `string` or an integral constant, not `%s`", cs.exp.toChars());
errors = true; errors = true;
} }
L1: L1:
foreach (cs2; *sw.cases) foreach (cs2; *sw.cases)
{ {
//printf("comparing '%s' with '%s'\n", exp.toChars(), cs.exp.toC hars()); //printf("comparing '%s' with '%s'\n", exp.toChars(), cs.exp.toC hars());
if (cs2.exp.equals(cs.exp)) if (cs2.exp.equals(cs.exp))
{ {
cs.error("duplicate `case %s` in `switch` statement", cs.exp // https://issues.dlang.org/show_bug.cgi?id=15909
.toChars()); cs.error("duplicate `case %s` in `switch` statement", initia
lExp.toChars());
errors = true; errors = true;
break; break;
} }
} }
sw.cases.push(cs); sw.cases.push(cs);
// Resolve any goto case's with no exp to this case statement // Resolve any goto case's with no exp to this case statement
for (size_t i = 0; i < sw.gotoCases.dim;) for (size_t i = 0; i < sw.gotoCases.dim;)
{ {
 End of changes. 2 change blocks. 
2 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)