Fail if break/continue statements are used outside for/while loops in ContractCompiler

This commit is contained in:
Alex Beregszaszi 2018-06-12 00:46:23 +01:00
parent 8999a2f375
commit 1d57d74e82

View File

@ -749,7 +749,7 @@ bool ContractCompiler::visit(ForStatement const& _forStatement)
bool ContractCompiler::visit(Continue const& _continueStatement) bool ContractCompiler::visit(Continue const& _continueStatement)
{ {
CompilerContext::LocationSetter locationSetter(m_context, _continueStatement); CompilerContext::LocationSetter locationSetter(m_context, _continueStatement);
if (!m_continueTags.empty()) solAssert(!m_continueTags.empty(), "");
m_context.appendJumpTo(m_continueTags.back()); m_context.appendJumpTo(m_continueTags.back());
return false; return false;
} }
@ -757,7 +757,7 @@ bool ContractCompiler::visit(Continue const& _continueStatement)
bool ContractCompiler::visit(Break const& _breakStatement) bool ContractCompiler::visit(Break const& _breakStatement)
{ {
CompilerContext::LocationSetter locationSetter(m_context, _breakStatement); CompilerContext::LocationSetter locationSetter(m_context, _breakStatement);
if (!m_breakTags.empty()) solAssert(!m_breakTags.empty(), "");
m_context.appendJumpTo(m_breakTags.back()); m_context.appendJumpTo(m_breakTags.back());
return false; return false;
} }