diff --git a/test/tools/ossfuzz/protoToYul.cpp b/test/tools/ossfuzz/protoToYul.cpp index 607629f69..a998e3255 100644 --- a/test/tools/ossfuzz/protoToYul.cpp +++ b/test/tools/ossfuzz/protoToYul.cpp @@ -311,7 +311,9 @@ void ProtoConverter::visit(ForStmt const& _x) m_output << "for { let " << loopVarName << " := 0 } " << "lt(" << loopVarName << ", 0x60) " << "{ " << loopVarName << " := add(" << loopVarName << ", 0x20) } "; + m_inForScope.push(true); visit(_x.for_body()); + m_inForScope.pop(); --m_numNestedForLoops; } @@ -365,6 +367,14 @@ void ProtoConverter::visit(Statement const& _x) case Statement::kSwitchstmt: visit(_x.switchstmt()); break; + case Statement::kBreakstmt: + if (m_inForScope.top()) + m_output << "break\n"; + break; + case Statement::kContstmt: + if (m_inForScope.top()) + m_output << "continue\n"; + break; case Statement::STMT_ONEOF_NOT_SET: break; } diff --git a/test/tools/ossfuzz/protoToYul.h b/test/tools/ossfuzz/protoToYul.h index eaef06539..b38bcda91 100644 --- a/test/tools/ossfuzz/protoToYul.h +++ b/test/tools/ossfuzz/protoToYul.h @@ -39,6 +39,7 @@ public: m_numLiveVars = 10; m_numVarsPerScope.push(m_numLiveVars); m_numNestedForLoops = 0; + m_inForScope.push(false); } ProtoConverter(ProtoConverter const&) = delete; ProtoConverter(ProtoConverter&&) = delete; @@ -72,6 +73,7 @@ private: std::stack m_numVarsPerScope; int32_t m_numLiveVars; int32_t m_numNestedForLoops; + std::stack m_inForScope; }; } } diff --git a/test/tools/ossfuzz/yulProto.proto b/test/tools/ossfuzz/yulProto.proto index 1dfcd98de..067cb7528 100644 --- a/test/tools/ossfuzz/yulProto.proto +++ b/test/tools/ossfuzz/yulProto.proto @@ -141,7 +141,7 @@ message IfStmt { } message ForStmt { - required Block for_body = 2; + required Block for_body = 1; } message CaseStmt { @@ -155,6 +155,9 @@ message SwitchStmt { optional Block default_block = 3; } +message BreakStmt {} +message ContinueStmt {} + message Statement { oneof stmt_oneof { VarDecl decl = 1; @@ -164,6 +167,8 @@ message Statement { Block blockstmt = 5; ForStmt forstmt = 6; SwitchStmt switchstmt = 7; + BreakStmt breakstmt = 8; + ContinueStmt contstmt = 9; } }