diff options
Diffstat (limited to 'libsolidity/inlineasm')
-rw-r--r-- | libsolidity/inlineasm/AsmAnalysis.cpp | 13 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmAnalysis.h | 2 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmCodeGen.cpp | 3 |
3 files changed, 12 insertions, 6 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp index b0d044ae..7e00ffae 100644 --- a/libsolidity/inlineasm/AsmAnalysis.cpp +++ b/libsolidity/inlineasm/AsmAnalysis.cpp @@ -65,7 +65,7 @@ bool AsmAnalyzer::operator()(assembly::Instruction const& _instruction) auto const& info = instructionInfo(_instruction.instruction); m_stackHeight += info.ret - info.args; m_info.stackHeightInfo[&_instruction] = m_stackHeight; - warnOnFutureInstruction(_instruction.instruction, _instruction.location); + warnOnInstructions(_instruction.instruction, _instruction.location); return true; } @@ -150,7 +150,6 @@ bool AsmAnalyzer::operator()(FunctionalInstruction const& _instr) if (!(*this)(_instr.instruction)) success = false; m_info.stackHeightInfo[&_instr] = m_stackHeight; - warnOnFutureInstruction(_instr.instruction.instruction, _instr.location); return success; } @@ -470,7 +469,7 @@ void AsmAnalyzer::expectValidType(string const& type, SourceLocation const& _loc ); } -void AsmAnalyzer::warnOnFutureInstruction(solidity::Instruction _instr, SourceLocation const& _location) +void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocation const& _location) { static set<solidity::Instruction> futureInstructions{ solidity::Instruction::CREATE2, @@ -486,4 +485,12 @@ void AsmAnalyzer::warnOnFutureInstruction(solidity::Instruction _instr, SourceLo + "\" instruction is only available after " + "the Metropolis hard fork. Before that it acts as an invalid instruction." ); + + if (_instr == solidity::Instruction::JUMP || _instr == solidity::Instruction::JUMPI) + m_errorReporter.warning( + _location, + "Jump instructions are low-level EVM features that can lead to " + "incorrect stack access. Because of that they are discouraged. " + "Please consider using \"switch\" or \"for\" statements instead." + ); } diff --git a/libsolidity/inlineasm/AsmAnalysis.h b/libsolidity/inlineasm/AsmAnalysis.h index 76d2eba1..9b2a8f9c 100644 --- a/libsolidity/inlineasm/AsmAnalysis.h +++ b/libsolidity/inlineasm/AsmAnalysis.h @@ -85,7 +85,7 @@ private: Scope& scope(assembly::Block const* _block); void expectValidType(std::string const& type, SourceLocation const& _location); - void warnOnFutureInstruction(solidity::Instruction _instr, SourceLocation const& _location); + void warnOnInstructions(solidity::Instruction _instr, SourceLocation const& _location); int m_stackHeight = 0; julia::ExternalIdentifierAccess::Resolver m_resolver; diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp index 2bbd1b70..74743737 100644 --- a/libsolidity/inlineasm/AsmCodeGen.cpp +++ b/libsolidity/inlineasm/AsmCodeGen.cpp @@ -137,7 +137,6 @@ private: eth::Assembly& m_assembly; }; - void assembly::CodeGenerator::assemble( Block const& _parsedData, AsmAnalysisInfo& _analysisInfo, @@ -146,5 +145,5 @@ void assembly::CodeGenerator::assemble( ) { EthAssemblyAdapter assemblyAdapter(_assembly); - julia::CodeTransform(assemblyAdapter, _analysisInfo, false, _identifierAccess)(_parsedData); + julia::CodeTransform(assemblyAdapter, _analysisInfo, false, false, _identifierAccess)(_parsedData); } |