From 420d373d89c438154d447a9bc1b87e5e2d256129 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 6 Feb 2012 14:28:07 -0800 Subject: [PATCH] Move assert so that an error is issued for "break" outside of loops. --- ctx.cpp | 3 ++- tests_errors/break.ispc | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests_errors/break.ispc 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; +}