From 5d9320c70b11b5ae1a44376451599732aa49dcde Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Tue, 3 Jul 2018 11:51:44 +0200 Subject: Disallow loos assembly in Solidity by permanently setting it to SyntaxError (from Warning) --- .../373_inline_assembly_unbalanced_positive_stack.sol | 2 +- .../374_inline_assembly_unbalanced_negative_stack.sol | 2 +- .../386_inline_assembly_050_literals_on_stack.sol | 11 ----------- .../387_inline_assembly_literals_on_stack.sol | 2 +- .../388_inline_assembly_050_bare_instructions.sol | 12 ------------ .../389_inline_assembly_bare_instructions.sol | 4 ++-- .../nameAndTypeResolution/390_inline_assembly_050_labels.sol | 11 ----------- .../nameAndTypeResolution/391_inline_assembly_labels.sol | 4 ++-- .../nameAndTypeResolution/393_inline_assembly_jump.sol | 3 +-- .../395_inline_assembly_leave_items_on_stack.sol | 2 +- .../viewPureChecker/assembly_jump_no_restrict_warning.sol | 2 +- .../syntaxTests/viewPureChecker/assembly_jump_view_fail.sol | 3 +-- 12 files changed, 11 insertions(+), 47 deletions(-) delete mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol delete mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol delete mode 100644 test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol (limited to 'test') diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol index 273e1844..e9599f4b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/373_inline_assembly_unbalanced_positive_stack.sol @@ -6,5 +6,5 @@ contract test { } } // ---- -// Warning: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// SyntaxError: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. // DeclarationError: (59-84): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol index bda090b4..9768a014 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol @@ -6,5 +6,5 @@ contract test { } } // ---- -// Warning: (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 deprecated. Please use functional notation instead. // DeclarationError: (59-86): Unbalanced stack at the end of a block: 1 missing item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol deleted file mode 100644 index a5f0f96c..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/386_inline_assembly_050_literals_on_stack.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() pure public { - assembly { - 1 - } - } -} -// ---- -// SyntaxError: (105-106): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. -// DeclarationError: (91-116): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol index 7b68c60b..62fe7171 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/387_inline_assembly_literals_on_stack.sol @@ -6,5 +6,5 @@ contract C { } } // ---- -// Warning: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// SyntaxError: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. // DeclarationError: (61-86): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol deleted file mode 100644 index 4a7aca8a..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/388_inline_assembly_050_bare_instructions.sol +++ /dev/null @@ -1,12 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() view public { - assembly { - address - pop - } - } -} -// ---- -// SyntaxError: (105-112): The use of non-functional instructions is deprecated. Please use functional notation instead. -// SyntaxError: (125-128): The use of non-functional instructions is deprecated. Please use functional notation instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol index c44412cf..fa706e7d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol @@ -7,5 +7,5 @@ contract C { } } // ---- -// Warning: (75-82): The use of non-functional instructions is deprecated. Please use functional notation instead. -// Warning: (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 deprecated. Please use functional notation instead. +// SyntaxError: (95-98): The use of non-functional instructions is deprecated. Please use functional notation instead. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol deleted file mode 100644 index 77a73ebc..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/390_inline_assembly_050_labels.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma experimental "v0.5.0"; -contract C { - function f() pure public { - assembly { - label: - } - } -} -// ---- -// SyntaxError: (105-110): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead. -// SyntaxError: (105-110): 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. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol index 15bd6660..8c820560 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol @@ -6,5 +6,5 @@ contract C { } } // ---- -// Warning: (75-80): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead. -// Warning: (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. +// SyntaxError: (75-80): The use of labels is deprecated. 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. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol index c3c82ce8..6cb35d6d 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/393_inline_assembly_jump.sol @@ -6,5 +6,4 @@ contract C { } } // ---- -// Warning: (75-82): 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: (75-82): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// SyntaxError: (75-82): 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. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol index 56043ccf..8538a2a0 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/395_inline_assembly_leave_items_on_stack.sol @@ -6,5 +6,5 @@ contract C { } } // ---- -// Warning: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. +// SyntaxError: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them. // DeclarationError: (61-93): Unbalanced stack at the end of a block: 1 surplus item(s). diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol index 418be561..cc6ef183 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// Warning: (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. +// 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. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol index c1729db7..933bb4a3 100644 --- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol +++ b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol @@ -4,5 +4,4 @@ contract C { } } // ---- -// Warning: (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. -// TypeError: (63-70): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable. +// 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. -- cgit v1.2.3 From 9b8a05ebfb34b0c4062cc6ab824b7281066424a6 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 9 Jul 2018 15:04:27 +0200 Subject: Update tests to remove support for loose assembly --- test/compilationTests/milestonetracker/RLP.sol | 9 ++-- test/libsolidity/SolidityEndToEndTest.cpp | 56 ++++------------------ test/libsolidity/SolidityNameAndTypeResolution.cpp | 10 ++-- .../function_call_invalid_argument_count.sol | 4 +- .../inlineAssembly/function_call_to_label.sol | 4 +- ...4_inline_assembly_unbalanced_negative_stack.sol | 2 +- .../389_inline_assembly_bare_instructions.sol | 4 +- .../391_inline_assembly_labels.sol | 2 +- .../assembly_jump_no_restrict_warning.sol | 7 --- .../viewPureChecker/assembly_jump_view_fail.sol | 7 --- 10 files changed, 24 insertions(+), 81 deletions(-) delete mode 100644 test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol delete mode 100644 test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol (limited to 'test') diff --git a/test/compilationTests/milestonetracker/RLP.sol b/test/compilationTests/milestonetracker/RLP.sol index e261bf23..e1f44457 100644 --- a/test/compilationTests/milestonetracker/RLP.sol +++ b/test/compilationTests/milestonetracker/RLP.sol @@ -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) } } diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index e9e7c93b..0437c72f 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -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; diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index d025e65a..41814888 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -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> expectations(vector>{ - {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>{ {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"} })); } diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol index cbea8991..ac1f541e 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_invalid_argument_count.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol index 5de492e1..150fb938 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/function_call_to_label.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol index 9768a014..342afc46 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/374_inline_assembly_unbalanced_negative_stack.sol @@ -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). diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol index fa706e7d..7315d5d1 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/389_inline_assembly_bare_instructions.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol index 8c820560..0d7bacb4 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/391_inline_assembly_labels.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol deleted file mode 100644 index cc6ef183..00000000 --- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_no_restrict_warning.sol +++ /dev/null @@ -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. diff --git a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol b/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol deleted file mode 100644 index 933bb4a3..00000000 --- a/test/libsolidity/syntaxTests/viewPureChecker/assembly_jump_view_fail.sol +++ /dev/null @@ -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. -- cgit v1.2.3 From a4ab305347c296e44e911765e4cd8c3243287e23 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 27 Jul 2018 13:40:07 +0200 Subject: Drop swap_peephole_optimization test from EndToEndTests Already covered by libevmasm/Optimiser: peephole_noncommutative_swap1, peephole_commutative_swap1 and peephole_swap_comparison --- test/libsolidity/SolidityEndToEndTest.cpp | 44 ------------------------------- 1 file changed, 44 deletions(-) (limited to 'test') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 0437c72f..d8b4b05d 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -12538,50 +12538,6 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure) } } -BOOST_AUTO_TEST_CASE(swap_peephole_optimisation) -{ - char const* sourceCode = R"( - contract C { - function lt(uint a, uint b) public returns (bool c) { - assembly { - a - b - swap1 - lt - =: c - } - } - function add(uint a, uint b) public returns (uint c) { - assembly { - a - b - swap1 - add - =: c - } - } - function div(uint a, uint b) public returns (uint c) { - assembly { - a - b - swap1 - div - =: c - } - } - } - )"; - compileAndRun(sourceCode); - BOOST_CHECK(callContractFunction("lt(uint256,uint256)", u256(1), u256(2)) == encodeArgs(u256(1))); - BOOST_CHECK(callContractFunction("lt(uint256,uint256)", u256(2), u256(1)) == encodeArgs(u256(0))); - BOOST_CHECK(callContractFunction("add(uint256,uint256)", u256(1), u256(2)) == encodeArgs(u256(3))); - BOOST_CHECK(callContractFunction("add(uint256,uint256)", u256(100), u256(200)) == encodeArgs(u256(300))); - BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(2), u256(1)) == encodeArgs(u256(2))); - BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(200), u256(10)) == encodeArgs(u256(20))); - BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(1), u256(0)) == encodeArgs(u256(0))); - BOOST_CHECK(callContractFunction("div(uint256,uint256)", u256(0), u256(1)) == encodeArgs(u256(0))); -} - BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople) { if (!dev::test::Options::get().evmVersion().hasBitwiseShifting()) -- cgit v1.2.3 From 43c01361f3bb1b2ffebbb82bb24ec7fecbb52d16 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Fri, 27 Jul 2018 13:40:25 +0200 Subject: Drops tests for inline assembly jumps and function access as both isn't possible anymore. --- test/libsolidity/SolidityEndToEndTest.cpp | 46 ------------------------------- 1 file changed, 46 deletions(-) (limited to 'test') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index d8b4b05d..45a56b22 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -8910,52 +8910,6 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_access_via_pointer) ABI_CHECK(callContractFunction("separator2()"), encodeArgs(u256(0))); } -BOOST_AUTO_TEST_CASE(inline_assembly_jumps) -{ - char const* sourceCode = R"( - contract C { - function f() public { - assembly { - let n := calldataload(4) - let a := 1 - let b := a - loop: - jumpi(loopend, eq(n, 0)) - a add swap1 - n := sub(n, 1) - jump(loop) - loopend: - mstore(0, a) - return(0, 0x20) - } - } - } - )"; - compileAndRun(sourceCode, 0, "C"); - ABI_CHECK(callContractFunction("f()", u256(5)), encodeArgs(u256(13))); - ABI_CHECK(callContractFunction("f()", u256(7)), encodeArgs(u256(34))); -} - -BOOST_AUTO_TEST_CASE(inline_assembly_function_access) -{ - char const* sourceCode = R"( - contract C { - uint public x; - function g(uint y) public { x = 2 * y; assembly { stop } } - function f(uint _x) public { - assembly { - _x - jump(g) - pop - } - } - } - )"; - compileAndRun(sourceCode, 0, "C"); - ABI_CHECK(callContractFunction("f(uint256)", u256(5)), encodeArgs()); - ABI_CHECK(callContractFunction("x()"), encodeArgs(u256(10))); -} - BOOST_AUTO_TEST_CASE(inline_assembly_function_call) { char const* sourceCode = R"( -- cgit v1.2.3