Merge pull request #4272 from ethereum/assert-break-continue

Fail if break/continue statements are used outside for/while loops in ContractCompiler
This commit is contained in:
chriseth 2018-06-13 12:10:39 +02:00 committed by GitHub
commit 014bbc6c97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -749,16 +749,16 @@ 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;
} }
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;
} }