Move assert so that an error is issued for "break" outside of loops.
This commit is contained in:
3
ctx.cpp
3
ctx.cpp
@@ -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
5
tests_errors/break.ispc
Normal file
@@ -0,0 +1,5 @@
|
||||
// "break" statement is illegal outside of
|
||||
|
||||
void foo() {
|
||||
break;
|
||||
}
|
||||
Reference in New Issue
Block a user