diff --git a/ctx.cpp b/ctx.cpp index e9fd7203..41178a5b 100644 --- a/ctx.cpp +++ b/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 diff --git a/tests_errors/break.ispc b/tests_errors/break.ispc new file mode 100644 index 00000000..35441569 --- /dev/null +++ b/tests_errors/break.ispc @@ -0,0 +1,5 @@ +// "break" statement is illegal outside of + +void foo() { + break; +}