aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/inlineasm/AsmAnalysis.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-03-05 19:10:49 +0800
committerGitHub <noreply@github.com>2018-03-05 19:10:49 +0800
commit6dc137317fa8249a9c1b19ff6430840974393f90 (patch)
tree2263fd97b42da5673b1dcce24ab4419ce8dc67b9 /libsolidity/inlineasm/AsmAnalysis.cpp
parente3c2ab39a125e68aea07ba9c8cacb0a55293bf0d (diff)
parent6ec4517929e8c0eca022f4771ba217db5d80beed (diff)
downloaddexon-solidity-6dc137317fa8249a9c1b19ff6430840974393f90.tar
dexon-solidity-6dc137317fa8249a9c1b19ff6430840974393f90.tar.gz
dexon-solidity-6dc137317fa8249a9c1b19ff6430840974393f90.tar.bz2
dexon-solidity-6dc137317fa8249a9c1b19ff6430840974393f90.tar.lz
dexon-solidity-6dc137317fa8249a9c1b19ff6430840974393f90.tar.xz
dexon-solidity-6dc137317fa8249a9c1b19ff6430840974393f90.tar.zst
dexon-solidity-6dc137317fa8249a9c1b19ff6430840974393f90.zip
Merge pull request #3569 from ethereum/evmVersion
EVM version
Diffstat (limited to 'libsolidity/inlineasm/AsmAnalysis.cpp')
-rw-r--r--libsolidity/inlineasm/AsmAnalysis.cpp50
1 files changed, 32 insertions, 18 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp
index 1030523a..a7f764a5 100644
--- a/libsolidity/inlineasm/AsmAnalysis.cpp
+++ b/libsolidity/inlineasm/AsmAnalysis.cpp
@@ -533,33 +533,47 @@ void AsmAnalyzer::expectValidType(string const& type, SourceLocation const& _loc
void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocation const& _location)
{
- static set<solidity::Instruction> futureInstructions{
- solidity::Instruction::CREATE2,
- solidity::Instruction::RETURNDATACOPY,
- solidity::Instruction::RETURNDATASIZE,
- solidity::Instruction::STATICCALL
- };
- if (futureInstructions.count(_instr))
+ // We assume that returndatacopy, returndatasize and staticcall are either all available
+ // or all not available.
+ solAssert(m_evmVersion.supportsReturndata() == m_evmVersion.hasStaticCall(), "");
+
+ if (_instr == solidity::Instruction::CREATE2)
m_errorReporter.warning(
_location,
"The \"" +
boost::to_lower_copy(instructionInfo(_instr).name)
- + "\" instruction is only available after " +
- "the Metropolis hard fork. Before that it acts as an invalid instruction."
+ + "\" instruction is not supported by the VM version \"" +
+ "" + m_evmVersion.name() +
+ "\" you are currently compiling for. " +
+ "It will be interpreted as an invalid instruction on this VM."
);
-
- static set<solidity::Instruction> experimentalInstructions{
- solidity::Instruction::SHL,
- solidity::Instruction::SHR,
- solidity::Instruction::SAR
- };
- if (experimentalInstructions.count(_instr))
+ else if ((
+ _instr == solidity::Instruction::RETURNDATACOPY ||
+ _instr == solidity::Instruction::RETURNDATASIZE ||
+ _instr == solidity::Instruction::STATICCALL
+ ) && !m_evmVersion.supportsReturndata())
+ m_errorReporter.warning(
+ _location,
+ "The \"" +
+ boost::to_lower_copy(instructionInfo(_instr).name)
+ + "\" instruction is only available for Byzantium-compatible VMs. " +
+ "You are currently compiling for \"" +
+ m_evmVersion.name() +
+ "\", where it will be interpreted as an invalid instruction."
+ );
+ else if ((
+ _instr == solidity::Instruction::SHL ||
+ _instr == solidity::Instruction::SHR ||
+ _instr == solidity::Instruction::SAR
+ ) && !m_evmVersion.hasBitwiseShifting())
m_errorReporter.warning(
_location,
"The \"" +
boost::to_lower_copy(instructionInfo(_instr).name)
- + "\" instruction is only available after " +
- "the Constantinople hard fork. Before that it acts as an invalid instruction."
+ + "\" instruction is only available for Constantinople-compatible VMs. " +
+ "You are currently compiling for \"" +
+ 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)