mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9316 from ethereum/yul-cleanup-evm
Tiny cleanups to EVMDialect in Yul
This commit is contained in:
commit
375cb09341
@ -558,6 +558,13 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio
|
||||
// Similarly we assume bitwise shifting and create2 go together.
|
||||
yulAssert(m_evmVersion.hasBitwiseShifting() == m_evmVersion.hasCreate2(), "");
|
||||
|
||||
// These instructions are disabled in the dialect.
|
||||
yulAssert(
|
||||
_instr != evmasm::Instruction::JUMP &&
|
||||
_instr != evmasm::Instruction::JUMPI &&
|
||||
_instr != evmasm::Instruction::JUMPDEST,
|
||||
"");
|
||||
|
||||
auto errorForVM = [&](ErrorId _errorId, string const& vmKindMessage) {
|
||||
m_errorReporter.typeError(
|
||||
_errorId,
|
||||
@ -602,19 +609,6 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio
|
||||
);
|
||||
else if (_instr == evmasm::Instruction::SELFBALANCE && !m_evmVersion.hasSelfBalance())
|
||||
errorForVM(3672_error, "only available for Istanbul-compatible");
|
||||
else if (
|
||||
_instr == evmasm::Instruction::JUMP ||
|
||||
_instr == evmasm::Instruction::JUMPI ||
|
||||
_instr == evmasm::Instruction::JUMPDEST
|
||||
)
|
||||
m_errorReporter.error(
|
||||
4316_error,
|
||||
Error::Type::SyntaxError,
|
||||
_location,
|
||||
"Jump instructions and labels are low-level EVM features that can lead to "
|
||||
"incorrect stack access. Because of that they are disallowed in strict assembly. "
|
||||
"Use functions, \"switch\", \"if\" or \"for\" statements instead."
|
||||
);
|
||||
else
|
||||
return false;
|
||||
|
||||
|
@ -114,12 +114,15 @@ pair<YulString, BuiltinFunctionForEVM> createFunction(
|
||||
map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVersion, bool _objectAccess)
|
||||
{
|
||||
map<YulString, BuiltinFunctionForEVM> builtins;
|
||||
// NOTE: Parser::instructions() will filter JUMPDEST and PUSHnn too
|
||||
for (auto const& instr: Parser::instructions())
|
||||
if (
|
||||
!evmasm::isDupInstruction(instr.second) &&
|
||||
!evmasm::isSwapInstruction(instr.second) &&
|
||||
!evmasm::isPushInstruction(instr.second) &&
|
||||
instr.second != evmasm::Instruction::JUMP &&
|
||||
instr.second != evmasm::Instruction::JUMPI &&
|
||||
instr.second != evmasm::Instruction::JUMPDEST &&
|
||||
_evmVersion.hasOpcode(instr.second)
|
||||
)
|
||||
builtins.emplace(createEVMFunction(instr.first, instr.second));
|
||||
|
@ -0,0 +1,9 @@
|
||||
contract C {
|
||||
function f() pure public {
|
||||
assembly {
|
||||
jumpi(2, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 4619: (75-80): Function not found.
|
Loading…
Reference in New Issue
Block a user