mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9433 from ethereum/reportAllStackErrors
Report all stack errors
This commit is contained in:
@@ -238,6 +238,7 @@ void CodeTransform::stackError(StackTooDeepError _error, int _targetStackHeight)
|
||||
m_assembly.appendConstant(u256(0));
|
||||
// Store error.
|
||||
m_stackErrors.emplace_back(std::move(_error));
|
||||
m_assembly.markAsInvalid();
|
||||
}
|
||||
|
||||
void CodeTransform::operator()(Assignment const& _assignment)
|
||||
@@ -436,31 +437,28 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
|
||||
m_context->functionExitPoints.push(
|
||||
CodeTransformContext::JumpInfo{m_assembly.newLabelId(), m_assembly.stackHeight()}
|
||||
);
|
||||
try
|
||||
CodeTransform subTransform(
|
||||
m_assembly,
|
||||
m_info,
|
||||
_function.body,
|
||||
m_allowStackOpt,
|
||||
m_dialect,
|
||||
m_builtinContext,
|
||||
m_evm15,
|
||||
m_identifierAccess,
|
||||
m_useNamedLabelsForFunctions,
|
||||
m_context
|
||||
);
|
||||
subTransform(_function.body);
|
||||
if (!subTransform.m_stackErrors.empty())
|
||||
{
|
||||
CodeTransform(
|
||||
m_assembly,
|
||||
m_info,
|
||||
_function.body,
|
||||
m_allowStackOpt,
|
||||
m_dialect,
|
||||
m_builtinContext,
|
||||
m_evm15,
|
||||
m_identifierAccess,
|
||||
m_useNamedLabelsForFunctions,
|
||||
m_context
|
||||
)(_function.body);
|
||||
}
|
||||
catch (StackTooDeepError const& _error)
|
||||
{
|
||||
// This exception will be re-thrown after the end of the surrounding block.
|
||||
// It enables us to see which functions compiled successfully and which did not.
|
||||
// Even if we emit actual code, add an illegal instruction to make sure that tests
|
||||
// will catch it.
|
||||
StackTooDeepError error(_error);
|
||||
if (error.functionName.empty())
|
||||
error.functionName = _function.name;
|
||||
stackError(std::move(error), static_cast<int>(height));
|
||||
m_assembly.markAsInvalid();
|
||||
for (StackTooDeepError& stackError: subTransform.m_stackErrors)
|
||||
{
|
||||
if (stackError.functionName.empty())
|
||||
stackError.functionName = _function.name;
|
||||
m_stackErrors.emplace_back(std::move(stackError));
|
||||
}
|
||||
}
|
||||
|
||||
m_assembly.appendLabel(m_context->functionExitPoints.top().label);
|
||||
@@ -606,9 +604,6 @@ void CodeTransform::operator()(Block const& _block)
|
||||
|
||||
finalizeBlock(_block, blockStartStackHeight);
|
||||
m_scope = originalScope;
|
||||
|
||||
if (!m_stackErrors.empty())
|
||||
BOOST_THROW_EXCEPTION(m_stackErrors.front());
|
||||
}
|
||||
|
||||
AbstractAssembly::LabelID CodeTransform::functionEntryID(YulString _name, Scope::Function const& _function)
|
||||
@@ -729,7 +724,8 @@ size_t CodeTransform::variableHeightDiff(Scope::Variable const& _var, YulString
|
||||
to_string(heightDiff - limit) +
|
||||
" slot(s) too deep inside the stack."
|
||||
);
|
||||
BOOST_THROW_EXCEPTION(m_stackErrors.back());
|
||||
m_assembly.markAsInvalid();
|
||||
return _forSwap ? 2 : 1;
|
||||
}
|
||||
return heightDiff;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user