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