Permalink
Browse files

Merge pull request #1430 from 9rnsr/fix9254

Issue 9254 - ICE on invalid foreach aggregate
  • Loading branch information...
2 parents 28a095d + 3a03684 commit f762d5920e5b0b03753bfa3aab82c71ec90cb876 @WalterBright WalterBright committed Jan 4, 2013
Showing with 50 additions and 48 deletions.
  1. +9 −48 src/statement.c
  2. +12 −0 test/fail_compilation/ice9254a.d
  3. +15 −0 test/fail_compilation/ice9254b.d
  4. +14 −0 test/fail_compilation/ice9254c.d
View
57 src/statement.c
@@ -1102,46 +1102,20 @@ bool WhileStatement::hasContinue()
bool WhileStatement::usesEH()
{
- assert(0);
- return body ? body->usesEH() : 0;
+ assert(global.errors);
+ return 0;
}
int WhileStatement::blockExit(bool mustNotThrow)
{
- assert(0);
- //printf("WhileStatement::blockExit(%p)\n", this);
-
- int result = BEnone;
- if (condition->canThrow(mustNotThrow))
- result |= BEthrow;
- if (condition->isBool(TRUE))
- {
- if (body)
- { result |= body->blockExit(mustNotThrow);
- if (result & BEbreak)
- result |= BEfallthru;
- }
- }
- else if (condition->isBool(FALSE))
- {
- result |= BEfallthru;
- }
- else
- {
- if (body)
- result |= body->blockExit(mustNotThrow);
- result |= BEfallthru;
- }
- result &= ~(BEbreak | BEcontinue);
- return result;
+ assert(global.errors);
+ return BEfallthru;
}
int WhileStatement::comeFrom()
{
- assert(0);
- if (body)
- return body->comeFrom();
+ assert(global.errors);
return FALSE;
}
@@ -2651,33 +2625,20 @@ bool ForeachRangeStatement::hasContinue()
bool ForeachRangeStatement::usesEH()
{
- assert(0);
+ assert(global.errors);
return body->usesEH();
}
int ForeachRangeStatement::blockExit(bool mustNotThrow)
{
- assert(0);
- int result = BEfallthru;
-
- if (lwr && lwr->canThrow(mustNotThrow))
- result |= BEthrow;
- else if (upr && upr->canThrow(mustNotThrow))
- result |= BEthrow;
-
- if (body)
- {
- result |= body->blockExit(mustNotThrow) & ~(BEbreak | BEcontinue);
- }
- return result;
+ assert(global.errors);
+ return BEfallthru;
}
int ForeachRangeStatement::comeFrom()
{
- assert(0);
- if (body)
- return body->comeFrom();
+ assert(global.errors);
return FALSE;
}
View
12 test/fail_compilation/ice9254a.d
@@ -0,0 +1,12 @@
+
+void main()
+{
+ foreach (divisor; !(2, 3, 4, 8, 7, 9))
+ {
+ // ice in ForeachRangeStatement::blockExit()
+ foreach (v; 0..uint.max) {}
+
+ // ice in WhileStatement::blockExit()
+ while (1) {}
+ }
+}
View
15 test/fail_compilation/ice9254b.d
@@ -0,0 +1,15 @@
+
+class C
+{
+ synchronized void foo()
+ {
+ foreach(divisor; !(2, 3, 4, 8, 7, 9))
+ {
+ // ice in ForeachRangeStatement::usesEH()
+ foreach (v; 0..uint.max) {}
+
+ // ice in WhileStatement::usesEH()
+ while (1) {}
+ }
+ }
+}
View
14 test/fail_compilation/ice9254c.d
@@ -0,0 +1,14 @@
+
+void main()
+{
+ foreach(divisor; !(2, 3, 4, 8, 7, 9))
+ {
+ assert(0);
+
+ // ice in ForeachRangeStatement::comeFrom()
+ foreach (v; 0..uint.max) {}
+
+ // ice in WhileStatement::comeFrom()
+ while (1) {}
+ }
+}

0 comments on commit f762d59

Please sign in to comment.