mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
wip
This commit is contained in:
parent
2dc5435c19
commit
0f08a06046
@ -664,7 +664,22 @@ bool AsmAnalyzer::validateInstructions(std::string const& _instructionIdentifier
|
||||
{
|
||||
auto const builtin = EVMDialect::strictAssemblyForEVM(EVMVersion{}).builtin(YulString(_instructionIdentifier));
|
||||
if (builtin && builtin->instruction.has_value())
|
||||
{
|
||||
if (_instructionIdentifier == "prevrandao" && !m_evmVersion.hasPrevRandao())
|
||||
m_errorReporter.warning(
|
||||
5761_error,
|
||||
_location,
|
||||
"\"prevrandao\" is not supported by the VM version and will be treated like \"difficulty\"."
|
||||
);
|
||||
else if (_instructionIdentifier == "difficulty" && m_evmVersion.hasPrevRandao())
|
||||
m_errorReporter.warning(
|
||||
3242_error,
|
||||
_location,
|
||||
"\"difficulty\" was renamed and supplanted by \"prevrandao\" in the VM version paris."
|
||||
);
|
||||
|
||||
return validateInstructions(builtin->instruction.value(), _location);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@ -684,6 +699,8 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio
|
||||
_instr != evmasm::Instruction::JUMPDEST,
|
||||
"");
|
||||
|
||||
bool returnValue = true;
|
||||
|
||||
auto errorForVM = [&](ErrorId _errorId, string const& vmKindMessage) {
|
||||
m_errorReporter.typeError(
|
||||
_errorId,
|
||||
@ -695,6 +712,7 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio
|
||||
fmt::arg("version", m_evmVersion.name())
|
||||
)
|
||||
);
|
||||
returnValue = false;
|
||||
};
|
||||
|
||||
if (_instr == evmasm::Instruction::RETURNDATACOPY && !m_evmVersion.supportsReturndata())
|
||||
@ -727,10 +745,8 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio
|
||||
"PC instruction is a low-level EVM feature. "
|
||||
"Because of that PC is disallowed in strict assembly."
|
||||
);
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
bool AsmAnalyzer::validateInstructions(FunctionCall const& _functionCall)
|
||||
|
@ -146,7 +146,7 @@ set<YulString> createReservedIdentifiers(langutil::EVMVersion _evmVersion)
|
||||
|
||||
map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVersion, bool _objectAccess)
|
||||
{
|
||||
auto hasOpCode = [&](evmasm::Instruction _instr, string const& _instrName) -> bool
|
||||
/*auto hasOpCode = [&](evmasm::Instruction _instr, string const& _instrName) -> bool
|
||||
{
|
||||
if (
|
||||
_instr == evmasm::Instruction::PREVRANDAO &&
|
||||
@ -155,7 +155,7 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
|
||||
return _evmVersion.hasPrevRandao();
|
||||
|
||||
return _evmVersion.hasOpcode(_instr);
|
||||
};
|
||||
};*/
|
||||
|
||||
map<YulString, BuiltinFunctionForEVM> builtins;
|
||||
for (auto const& instr: evmasm::c_instructions)
|
||||
@ -170,7 +170,7 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
|
||||
opcode != evmasm::Instruction::JUMP &&
|
||||
opcode != evmasm::Instruction::JUMPI &&
|
||||
opcode != evmasm::Instruction::JUMPDEST &&
|
||||
hasOpCode(opcode, name)
|
||||
_evmVersion.hasOpcode(opcode)
|
||||
)
|
||||
builtins.emplace(createEVMFunction(name, opcode));
|
||||
}
|
||||
|
@ -4,4 +4,4 @@ function f() view returns (uint) {
|
||||
// ====
|
||||
// EVMVersion: >=paris
|
||||
// ----
|
||||
// Warning 8417: (43-59): "difficulty" was renamed and supplanted by "prevrandao" in the VM version paris.
|
||||
// Warning 8417: (46-62): "difficulty" was renamed and supplanted by "prevrandao" in the VM version paris.
|
||||
|
@ -4,4 +4,4 @@ function f() view returns (uint) {
|
||||
// ====
|
||||
// EVMVersion: <paris
|
||||
// ----
|
||||
// Warning 9432: (43-59): "prevrandao" is not supported by the VM version and will be treated like "difficulty".
|
||||
// Warning 9432: (46-62): "prevrandao" is not supported by the VM version and will be treated like "difficulty".
|
||||
|
@ -73,7 +73,7 @@ contract C {
|
||||
pop(coinbase())
|
||||
pop(timestamp())
|
||||
pop(number())
|
||||
pop(difficulty())
|
||||
pop(prevrandao())
|
||||
pop(gaslimit())
|
||||
|
||||
// NOTE: msize() is allowed only with optimizer disabled
|
||||
@ -83,7 +83,7 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=london
|
||||
// EVMVersion: >=paris
|
||||
// ----
|
||||
// Warning 5740: (89-1716): Unreachable code.
|
||||
// Warning 5740: (1729-1741): Unreachable code.
|
||||
|
@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function f() public {
|
||||
assembly {
|
||||
pop(difficulty())
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: =london
|
||||
// ----
|
||||
// Warning 5740: (89-1716): Unreachable code.
|
||||
// Warning 5740: (1729-1741): Unreachable code.
|
||||
// Warning 5740: (1754-1769): Unreachable code.
|
||||
// Warning 5740: (1782-1791): Unreachable code.
|
||||
// Warning 5740: (1804-2215): Unreachable code.
|
@ -9,7 +9,3 @@ contract C {
|
||||
// ====
|
||||
// EVMVersion: =london
|
||||
// ----
|
||||
// Warning 5740: (94-1733): Unreachable code.
|
||||
// Warning 5740: (1746-1758): Unreachable code.
|
||||
// Warning 5740: (1801-1810): Unreachable code.
|
||||
// Warning 5740: (1978-2244): Unreachable code.
|
||||
|
@ -9,37 +9,4 @@ contract C {
|
||||
// ====
|
||||
// EVMVersion: =london
|
||||
// ----
|
||||
// Warning 5740: (672-1083): Unreachable code.
|
||||
// TypeError 2527: (79-87): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 8961: (101-113): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 2527: (130-135): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (153-162): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (180-190): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (208-221): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (239-247): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (265-276): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (294-308): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (322-345): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (362-376): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 8961: (394-409): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 8961: (427-446): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 8961: (464-489): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 8961: (507-536): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 8961: (554-584): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 2527: (602-630): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 8961: (644-659): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 8961: (672-682): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 8961: (695-708): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 8961: (721-737): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 8961: (750-769): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 8961: (782-804): Function cannot be declared as pure because this expression (potentially) modifies the state.
|
||||
// TypeError 2527: (821-830): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (848-857): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (875-883): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (901-911): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (929-941): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (959-969): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (987-998): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (1016-1024): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (1042-1054): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (1072-1082): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
// TypeError 2527: (111-123): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
|
||||
|
Loading…
Reference in New Issue
Block a user