Move assert so that an error is issued for "break" outside of loops.

This commit is contained in:
Matt Pharr
2012-02-06 14:28:07 -08:00
parent a59fd7eeb3
commit 420d373d89
2 changed files with 7 additions and 1 deletions

View File

@@ -642,12 +642,12 @@ FunctionEmitContext::inSwitchStatement() const {
void
FunctionEmitContext::Break(bool doCoherenceCheck) {
Assert(controlFlowInfo.size() > 0);
if (breakTarget == NULL) {
Error(currentPos, "\"break\" statement is illegal outside of "
"for/while/do loops and \"switch\" statements.");
return;
}
Assert(controlFlowInfo.size() > 0);
if (bblock == NULL)
return;
@@ -721,6 +721,7 @@ FunctionEmitContext::Continue(bool doCoherenceCheck) {
"for/while/do/foreach loops.");
return;
}
Assert(controlFlowInfo.size() > 0);
if (ifsInCFAllUniform(CFInfo::Loop) || GetInternalMask() == LLVMMaskAllOn) {
// Similarly to 'break' statements, we can immediately jump to the

5
tests_errors/break.ispc Normal file
View File

@@ -0,0 +1,5 @@
// "break" statement is illegal outside of
void foo() {
break;
}