From 53bc0ff18e8daa82a3bfb096b48cb019e3fb5aa5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 20 Jul 2020 14:52:10 +0200 Subject: [PATCH 1/2] Fix "enforce via yul". --- test/libsolidity/SemanticTest.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index e3b40f1e4..180e49bd7 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -46,7 +46,7 @@ SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVer m_lineOffset(m_reader.lineNumber()), m_enforceViaYul(enforceViaYul) { - string choice = m_reader.stringSetting("compileViaYul", "false"); + string choice = m_reader.stringSetting("compileViaYul", "default"); if (choice == "also") { m_runWithYul = true; @@ -64,6 +64,11 @@ SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVer // Do not try to run via yul if explicitly denied. m_enforceViaYul = false; } + else if (choice == "default") + { + m_runWithYul = false; + m_runWithoutYul = true; + } else BOOST_THROW_EXCEPTION(runtime_error("Invalid compileViaYul value: " + choice + ".")); From 0a25370eebf603531f92ee15e5156fbdf7c941f3 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 20 Jul 2020 15:06:45 +0200 Subject: [PATCH 2/2] Update tests. --- test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol | 2 ++ .../semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol | 2 ++ test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol | 2 ++ .../abiEncoderV2/calldata_struct_member_offset.sol | 2 ++ .../semanticTests/array/calldata_array_of_struct.sol | 2 ++ .../semanticTests/array/fixed_arrays_in_storage.sol | 2 ++ .../semanticTests/calldata/calldata_bytes_external.sol | 1 + .../semanticTests/calldata/calldata_struct_cleaning.sol | 2 ++ .../semanticTests/calldata/calldata_struct_internal.sol | 2 ++ test/libsolidity/semanticTests/dirty_calldata_bytes.sol | 4 +++- .../semanticTests/dirty_calldata_dynamic_array.sol | 4 +++- .../semanticTests/functionCall/call_options_overload.sol | 2 ++ .../libraries/internal_library_function_bound.sol | 2 ++ .../libraries/internal_library_function_return_var_size.sol | 2 ++ test/libsolidity/semanticTests/multiSource/import.sol | 2 ++ test/libsolidity/semanticTests/smoke/structs.sol | 2 ++ .../semanticTests/storage/packed_storage_structs_bytes.sol | 2 ++ .../semanticTests/storage/packed_storage_structs_enum.sol | 2 ++ .../semanticTests/storage/packed_storage_structs_uint.sol | 2 ++ test/libsolidity/semanticTests/strings/unicode_escapes.sol | 2 ++ test/libsolidity/semanticTests/strings/unicode_string.sol | 2 ++ .../semanticTests/structs/calldata/calldata_struct.sol | 2 ++ .../structs/calldata/calldata_struct_and_ints.sol | 2 ++ .../semanticTests/structs/calldata/calldata_structs.sol | 2 ++ .../semanticTests/structs/calldata/dynamic_nested.sol | 2 ++ .../semanticTests/structs/calldata/dynamically_encoded.sol | 2 ++ .../semanticTests/various/cross_contract_types.sol | 2 ++ test/libsolidity/semanticTests/various/memory_overwrite.sol | 2 ++ .../semanticTests/various/negative_stack_height.sol | 3 ++- 29 files changed, 59 insertions(+), 3 deletions(-) diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol index 1dbf320bd..6d7b27f58 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2.sol @@ -18,5 +18,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol index a5e7a9af8..9ed9ada78 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_calldata.sol @@ -12,5 +12,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f(bytes): 0x20, 0xe0, 0x20, 0x21, 0x40, 0x3, 0xa, 0xb, 0xc -> 0x20, 0x21, 0x40, 0x3, 0xa, 0xb, 0xc diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol index f6510b53d..bfa750712 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol @@ -45,6 +45,8 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f0() -> 0x20, 0x0 // f1() -> 0x20, 0x40, 0x1, 0x2 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol index fb8e6c3c5..196967a44 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_member_offset.sol @@ -19,5 +19,7 @@ contract C { return (b.b, this.g(b)); } } +// ==== +// compileViaYul: also // ---- // f() -> 11, 11 diff --git a/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol b/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol index 333112265..170dee6ee 100644 --- a/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol +++ b/test/libsolidity/semanticTests/array/calldata_array_of_struct.sol @@ -20,5 +20,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f((uint256,uint256)[]): 0x20, 0x2, 0x1, 0x2, 0x3, 0x4 -> 2, 1, 2, 3, 4 diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol b/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol index b65a3d254..3f5c0d5dd 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_in_storage.sol @@ -33,6 +33,8 @@ contract c { l2 = ids.length; } } +// ==== +// compileViaYul: also // ---- // setIDStatic(uint256): 0xb -> // getID(uint256): 0x2 -> 0xb diff --git a/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol b/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol index 9917e736a..9be9e8eab 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_bytes_external.sol @@ -7,6 +7,7 @@ contract CalldataTest { } } // ==== +// compileViaYul: also // EVMVersion: >=byzantium // ---- // tester(bytes): 0x20, 0x08, "abcdefgh" -> "c" diff --git a/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol b/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol index dbf6e4440..6b4eb2f07 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_struct_cleaning.sol @@ -16,6 +16,8 @@ contract C { } } } +// ==== +// compileViaYul: also // ---- // f((uint8,bytes1)): 0x12, hex"3400000000000000000000000000000000000000000000000000000000000000" -> 0x12, hex"3400000000000000000000000000000000000000000000000000000000000000" # double check that the valid case goes through # // f((uint8,bytes1)): 0x1234, hex"5678000000000000000000000000000000000000000000000000000000000000" -> FAILURE diff --git a/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol b/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol index a463b5d33..810900dd6 100644 --- a/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol +++ b/test/libsolidity/semanticTests/calldata/calldata_struct_internal.sol @@ -13,5 +13,7 @@ contract C { return f(s); } } +// ==== +// compileViaYul: also // ---- // f(uint256,(uint256,uint256),uint256): 7, 1, 2, 4 -> 1, 2 diff --git a/test/libsolidity/semanticTests/dirty_calldata_bytes.sol b/test/libsolidity/semanticTests/dirty_calldata_bytes.sol index 05a3793f6..f3cd7b912 100644 --- a/test/libsolidity/semanticTests/dirty_calldata_bytes.sol +++ b/test/libsolidity/semanticTests/dirty_calldata_bytes.sol @@ -8,5 +8,7 @@ contract C { correct = r == (0x64 << 248); } } +// ==== +// compileViaYul: also // ---- -// f(bytes): 0x20, 0x04, "dead" -> true \ No newline at end of file +// f(bytes): 0x20, 0x04, "dead" -> true diff --git a/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol b/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol index 1c9d7db30..df5c672d1 100644 --- a/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol +++ b/test/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol @@ -8,5 +8,7 @@ contract C { correct = r == 0x7fff; } } +// ==== +// compileViaYul: also // ---- -// f(int16[]): 0x20, 0x02, 0x7fff, 0x7fff -> true \ No newline at end of file +// f(int16[]): 0x20, 0x02, 0x7fff, 0x7fff -> true diff --git a/test/libsolidity/semanticTests/functionCall/call_options_overload.sol b/test/libsolidity/semanticTests/functionCall/call_options_overload.sol index 27e8e4127..8938d8f0c 100644 --- a/test/libsolidity/semanticTests/functionCall/call_options_overload.sol +++ b/test/libsolidity/semanticTests/functionCall/call_options_overload.sol @@ -9,6 +9,8 @@ contract C { } receive() external payable {} } +// ==== +// compileViaYul: also // ---- // (), 1 ether // call() -> 1, 2, 2, 2 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol index f59ec9440..a6ea94fed 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_bound.sol @@ -22,5 +22,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol b/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol index 21417b599..1406e0117 100644 --- a/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol +++ b/test/libsolidity/semanticTests/libraries/internal_library_function_return_var_size.sol @@ -22,5 +22,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f() -> 2 diff --git a/test/libsolidity/semanticTests/multiSource/import.sol b/test/libsolidity/semanticTests/multiSource/import.sol index 2a0f43d53..d3f5ed301 100644 --- a/test/libsolidity/semanticTests/multiSource/import.sol +++ b/test/libsolidity/semanticTests/multiSource/import.sol @@ -7,6 +7,8 @@ import "A"; contract B is A { function f(uint256 x) public view returns(uint256) { return x; } } +// ==== +// compileViaYul: also // ---- // f(uint256): 1337 -> 1337 // g(uint256): 1337 -> 1338 diff --git a/test/libsolidity/semanticTests/smoke/structs.sol b/test/libsolidity/semanticTests/smoke/structs.sol index 979dbdcc0..6a7286e57 100644 --- a/test/libsolidity/semanticTests/smoke/structs.sol +++ b/test/libsolidity/semanticTests/smoke/structs.sol @@ -17,6 +17,8 @@ contract C { return T(23, 42, "any"); } } +// ==== +// compileViaYul: also // ---- // s() -> 23, 42 // t() -> 0x20, 23, 42, 0x60, 3, "any" diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol index daeee6ba6..50a0d68f7 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol @@ -41,5 +41,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // test() -> true diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol index 9c9f778f0..3f2983f46 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_enum.sol @@ -29,5 +29,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // test() -> 1 diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol index 8c91576f5..611fda3cc 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_uint.sol @@ -26,5 +26,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // test() -> 1 diff --git a/test/libsolidity/semanticTests/strings/unicode_escapes.sol b/test/libsolidity/semanticTests/strings/unicode_escapes.sol index 401d8b61e..fc57aa48e 100644 --- a/test/libsolidity/semanticTests/strings/unicode_escapes.sol +++ b/test/libsolidity/semanticTests/strings/unicode_escapes.sol @@ -15,6 +15,8 @@ contract C { return "\u0024\u00A2\u20AC"; } } +// ==== +// compileViaYul: also // ---- // oneByteUTF8() -> 0x20, 7, "aaa$aaa" // twoBytesUTF8() -> 0x20, 8, "aaa\xc2\xa2aaa" diff --git a/test/libsolidity/semanticTests/strings/unicode_string.sol b/test/libsolidity/semanticTests/strings/unicode_string.sol index c139d6b8b..73616e479 100644 --- a/test/libsolidity/semanticTests/strings/unicode_string.sol +++ b/test/libsolidity/semanticTests/strings/unicode_string.sol @@ -3,5 +3,7 @@ contract C { return "😃, 😭, and 😈"; } } +// ==== +// compileViaYul: also // ---- // f() -> 0x20, 0x14, "\xf0\x9f\x98\x83, \xf0\x9f\x98\xad, and \xf0\x9f\x98\x88" diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol index a7ecf2bd0..d3a79a181 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct.sol @@ -13,5 +13,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f((uint256,uint256)): 42, 23 -> 42, 23 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol index c3b8249e8..21fada9c2 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_and_ints.sol @@ -16,5 +16,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f(uint256,(uint256,uint256),uint256): 1, 2, 3, 4 -> 1, 2, 3, 4 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol index 4139c1073..0e62ee4ef 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_structs.sol @@ -23,5 +23,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f((uint256,uint256),(uint256),(uint256,uint256)): 1, 2, 3, 4, 5 -> 1, 2, 3, 4, 5 diff --git a/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol b/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol index 59cde3171..8d6b73103 100644 --- a/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol +++ b/test/libsolidity/semanticTests/structs/calldata/dynamic_nested.sol @@ -7,5 +7,7 @@ contract C { return (s.children.length, s.a, s.children[0].b, s.children[1].b); } } +// ==== +// compileViaYul: also // ---- // f((uint256,(uint256)[])): 32, 17, 64, 2, 23, 42 -> 2, 17, 23, 42 diff --git a/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol b/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol index 3acea52e7..815de9a28 100644 --- a/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol +++ b/test/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol @@ -6,5 +6,7 @@ contract C { return (s.a.length, s.a[0], s.a[1]); } } +// ==== +// compileViaYul: also // ---- // f((uint256[])): 32, 32, 2, 42, 23 -> 2, 42, 23 diff --git a/test/libsolidity/semanticTests/various/cross_contract_types.sol b/test/libsolidity/semanticTests/various/cross_contract_types.sol index 47842cc03..88528ce07 100644 --- a/test/libsolidity/semanticTests/various/cross_contract_types.sol +++ b/test/libsolidity/semanticTests/various/cross_contract_types.sol @@ -13,5 +13,7 @@ contract Test { } } +// ==== +// compileViaYul: also // ---- // f() -> 3 diff --git a/test/libsolidity/semanticTests/various/memory_overwrite.sol b/test/libsolidity/semanticTests/various/memory_overwrite.sol index 7312509e2..3ab0a2aa2 100644 --- a/test/libsolidity/semanticTests/various/memory_overwrite.sol +++ b/test/libsolidity/semanticTests/various/memory_overwrite.sol @@ -6,5 +6,7 @@ contract C { } } +// ==== +// compileViaYul: also // ---- // f() -> 0x20, 5, "b23a5" diff --git a/test/libsolidity/semanticTests/various/negative_stack_height.sol b/test/libsolidity/semanticTests/various/negative_stack_height.sol index d5074dc91..8f36538e4 100644 --- a/test/libsolidity/semanticTests/various/negative_stack_height.sol +++ b/test/libsolidity/semanticTests/various/negative_stack_height.sol @@ -58,6 +58,7 @@ contract C { ) {} } - +// ==== +// compileViaYul: false // ---- // constructor() ->