mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix assertion concerning jumps in strict assembly.
This commit is contained in:
parent
10888b21d8
commit
3a3ed1c6b5
@ -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."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
1
test/cmdlineTests/strict_asm_jump/args
Normal file
1
test/cmdlineTests/strict_asm_jump/args
Normal file
@ -0,0 +1 @@
|
||||
--strict-assembly
|
3
test/cmdlineTests/strict_asm_jump/err
Normal file
3
test/cmdlineTests/strict_asm_jump/err
Normal 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) }
|
||||
^-----^
|
1
test/cmdlineTests/strict_asm_jump/exit
Normal file
1
test/cmdlineTests/strict_asm_jump/exit
Normal file
@ -0,0 +1 @@
|
||||
1
|
1
test/cmdlineTests/strict_asm_jump/input.sol
Normal file
1
test/cmdlineTests/strict_asm_jump/input.sol
Normal file
@ -0,0 +1 @@
|
||||
{ jump(1) }
|
Loading…
Reference in New Issue
Block a user