mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update tests to remove support for loose assembly
This commit is contained in:
parent
ed3cb327ea
commit
9b8a05ebfb
@ -381,19 +381,16 @@ library RLP {
|
||||
// we can write entire words, and just overwrite any excess.
|
||||
assembly {
|
||||
{
|
||||
let i := 0 // Start at arr + 0x20
|
||||
let words := div(add(btsLen, 31), 32)
|
||||
let rOffset := btsPtr
|
||||
let wOffset := add(tgt, 0x20)
|
||||
tag_loop:
|
||||
jumpi(end, eq(i, words))
|
||||
|
||||
// Start at arr + 0x20
|
||||
for { let i := 0 } not(eq(i, words)) { i := add(i, 1) }
|
||||
{
|
||||
let offset := mul(i, 0x20)
|
||||
mstore(add(wOffset, offset), mload(add(rOffset, offset)))
|
||||
i := add(i, 1)
|
||||
}
|
||||
jump(tag_loop)
|
||||
end:
|
||||
mstore(add(tgt, add(0x20, mload(tgt))), 0)
|
||||
}
|
||||
}
|
||||
|
@ -11261,7 +11261,7 @@ BOOST_AUTO_TEST_CASE(invalid_instruction)
|
||||
contract C {
|
||||
function f() public {
|
||||
assembly {
|
||||
invalid
|
||||
invalid()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11688,19 +11688,10 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly)
|
||||
ret := keccak256(0, 0)
|
||||
}
|
||||
}
|
||||
function g() public pure returns (bytes32 ret) {
|
||||
assembly {
|
||||
0
|
||||
0
|
||||
keccak256
|
||||
=: ret
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
ABI_CHECK(callContractFunction("f()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
|
||||
ABI_CHECK(callContractFunction("g()"), fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(multi_modifiers)
|
||||
@ -12599,26 +12590,17 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
|
||||
contract C {
|
||||
function shl(uint a, uint b) public returns (uint c) {
|
||||
assembly {
|
||||
a
|
||||
b
|
||||
shl
|
||||
=: c
|
||||
c := shl(b, a)
|
||||
}
|
||||
}
|
||||
function shr(uint a, uint b) public returns (uint c) {
|
||||
assembly {
|
||||
a
|
||||
b
|
||||
shr
|
||||
=: c
|
||||
c := shr(b, a)
|
||||
}
|
||||
}
|
||||
function sar(uint a, uint b) public returns (uint c) {
|
||||
assembly {
|
||||
a
|
||||
b
|
||||
sar
|
||||
=: c
|
||||
c := sar(b, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12646,10 +12628,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
|
||||
function shl_1() public returns (bool) {
|
||||
uint c;
|
||||
assembly {
|
||||
1
|
||||
2
|
||||
shl
|
||||
=: c
|
||||
c := shl(2, 1)
|
||||
}
|
||||
assert(c == 4);
|
||||
return true;
|
||||
@ -12657,10 +12636,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
|
||||
function shl_2() public returns (bool) {
|
||||
uint c;
|
||||
assembly {
|
||||
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
1
|
||||
shl
|
||||
=: c
|
||||
c := shl(1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
|
||||
}
|
||||
assert(c == 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe);
|
||||
return true;
|
||||
@ -12668,10 +12644,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
|
||||
function shl_3() public returns (bool) {
|
||||
uint c;
|
||||
assembly {
|
||||
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
256
|
||||
shl
|
||||
=: c
|
||||
c := shl(256, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
|
||||
}
|
||||
assert(c == 0);
|
||||
return true;
|
||||
@ -12679,10 +12652,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
|
||||
function shr_1() public returns (bool) {
|
||||
uint c;
|
||||
assembly {
|
||||
3
|
||||
1
|
||||
shr
|
||||
=: c
|
||||
c := shr(1, 3)
|
||||
}
|
||||
assert(c == 1);
|
||||
return true;
|
||||
@ -12690,10 +12660,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
|
||||
function shr_2() public returns (bool) {
|
||||
uint c;
|
||||
assembly {
|
||||
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
1
|
||||
shr
|
||||
=: c
|
||||
c := shr(1, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
|
||||
}
|
||||
assert(c == 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
|
||||
return true;
|
||||
@ -12701,10 +12668,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
|
||||
function shr_3() public returns (bool) {
|
||||
uint c;
|
||||
assembly {
|
||||
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
256
|
||||
shr
|
||||
=: c
|
||||
c := shr(256, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
|
||||
}
|
||||
assert(c == 0);
|
||||
return true;
|
||||
|
@ -390,12 +390,10 @@ BOOST_AUTO_TEST_CASE(unsatisfied_version)
|
||||
BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract c { function f() public { uint returndatasize; assembly { returndatasize }}}
|
||||
contract C { function f() public pure { uint returndatasize; returndatasize; assembly { pop(returndatasize()) }}}
|
||||
)";
|
||||
vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
|
||||
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"},
|
||||
{Error::Type::Warning, "The use of non-functional instructions is deprecated."},
|
||||
{Error::Type::DeclarationError, "Unbalanced stack"}
|
||||
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
|
||||
});
|
||||
if (!dev::test::Options::get().evmVersion().supportsReturndata())
|
||||
expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible")));
|
||||
@ -405,15 +403,13 @@ BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
|
||||
BOOST_AUTO_TEST_CASE(create2_as_variable)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract c { function f() public { uint create2; assembly { create2(0, 0, 0, 0) } }}
|
||||
contract c { function f() public { uint create2; create2; assembly { pop(create2(0, 0, 0, 0)) } }}
|
||||
)";
|
||||
// This needs special treatment, because the message mentions the EVM version,
|
||||
// so cannot be run via isoltest.
|
||||
CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
|
||||
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"},
|
||||
{Error::Type::Warning, "The \"create2\" instruction is not supported by the VM version"},
|
||||
{Error::Type::DeclarationError, "Unbalanced stack"},
|
||||
{Error::Type::Warning, "not supposed to return values"}
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,6 @@ contract C {
|
||||
}
|
||||
// ----
|
||||
// TypeError: (87-88): Expected 1 arguments but got 0.
|
||||
// Warning: (87-90): Top-level expressions are not supposed to return values (this expression returns -1 values). Use ``pop()`` or assign them.
|
||||
// SyntaxError: (87-90): Top-level expressions are not supposed to return values (this expression returns -1 values). Use ``pop()`` or assign them.
|
||||
// TypeError: (108-109): Expected 1 arguments but got 2.
|
||||
// Warning: (108-115): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
|
||||
// SyntaxError: (108-115): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
|
||||
|
@ -8,6 +8,6 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (63-64): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
|
||||
// Warning: (63-64): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
||||
// SyntaxError: (63-64): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead.
|
||||
// SyntaxError: (63-64): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
||||
// TypeError: (73-74): Attempt to call label instead of function.
|
||||
|
@ -6,5 +6,5 @@ contract test {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (73-76): The use of non-functional instructions is deprecated. Please use functional notation instead.
|
||||
// SyntaxError: (73-76): The use of non-functional instructions is disallowed. Please use functional notation instead.
|
||||
// DeclarationError: (59-86): Unbalanced stack at the end of a block: 1 missing item(s).
|
||||
|
@ -7,5 +7,5 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (75-82): The use of non-functional instructions is deprecated. Please use functional notation instead.
|
||||
// SyntaxError: (95-98): The use of non-functional instructions is deprecated. Please use functional notation instead.
|
||||
// SyntaxError: (75-82): The use of non-functional instructions is disallowed. Please use functional notation instead.
|
||||
// SyntaxError: (95-98): The use of non-functional instructions is disallowed. Please use functional notation instead.
|
||||
|
@ -6,5 +6,5 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (75-80): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
|
||||
// SyntaxError: (75-80): The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead.
|
||||
// SyntaxError: (75-80): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
||||
|
@ -1,7 +0,0 @@
|
||||
contract C {
|
||||
function k() public {
|
||||
assembly { jump(2) }
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (58-65): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
@ -1,7 +0,0 @@
|
||||
contract C {
|
||||
function k() public view {
|
||||
assembly { jump(2) }
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (63-70): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
Loading…
Reference in New Issue
Block a user