Fix assertion concerning jumps in strict assembly.

This commit is contained in:
chriseth 2019-02-13 14:50:00 +01:00
parent 10888b21d8
commit 3a3ed1c6b5
5 changed files with 24 additions and 12 deletions

View File

@ -638,6 +638,7 @@ void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocatio
solAssert(m_evmVersion.supportsReturndata() == m_evmVersion.hasStaticCall(), "");
// Similarly we assume bitwise shifting and create2 go together.
solAssert(m_evmVersion.hasBitwiseShifting() == m_evmVersion.hasCreate2(), "");
solAssert(m_dialect->flavour != AsmFlavour::Yul, "");
if (_instr == solidity::Instruction::EXTCODEHASH)
m_errorReporter.warning(
@ -678,12 +679,9 @@ void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocatio
m_evmVersion.name() +
"\", where it will be interpreted as an invalid instruction."
);
if (_instr == solidity::Instruction::JUMP || _instr == solidity::Instruction::JUMPI || _instr == solidity::Instruction::JUMPDEST)
else if (_instr == solidity::Instruction::JUMP || _instr == solidity::Instruction::JUMPI || _instr == solidity::Instruction::JUMPDEST)
{
if (m_dialect->flavour != AsmFlavour::Loose)
solAssert(m_errorTypeForLoose && *m_errorTypeForLoose != Error::Type::Warning, "");
if (m_dialect->flavour == AsmFlavour::Loose)
m_errorReporter.error(
m_errorTypeForLoose ? *m_errorTypeForLoose : Error::Type::Warning,
_location,
@ -691,6 +689,14 @@ void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocatio
"incorrect stack access. Because of that they are discouraged. "
"Please consider using \"switch\", \"if\" or \"for\" statements instead."
);
else
m_errorReporter.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."
);
}
}

View File

@ -0,0 +1 @@
--strict-assembly

View File

@ -0,0 +1,3 @@
strict_asm_jump/input.sol:1:3: Error: 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.
{ jump(1) }
^-----^

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
{ jump(1) }