From 381ed5a3025914ac75b60ee4dd856b5d97d5bf93 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Mon, 29 Apr 2019 14:27:10 +0200 Subject: [PATCH] Unifies behavior for member access of ABI functions. --- libsolidity/codegen/ExpressionCompiler.cpp | 2 +- ...access.sol => abi_functions_member_access.sol} | 3 +++ .../abi_functions_member_access.sol | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) rename test/libsolidity/semanticTests/specialFunctions/{abi_encode_decode_member_access.sol => abi_functions_member_access.sol} (54%) create mode 100644 test/libsolidity/syntaxTests/specialFunctions/abi_functions_member_access.sol diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 6a3d8e9b2..bde4a167b 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1401,7 +1401,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) m_context << Instruction::DUP1 << u256(32) << Instruction::ADD; utils().storeStringData(contract.name()); } - else if (member == "encode" || member == "decode") + else if ((set{"encode", "encodePacked", "encodeWithSelector", "encodeWithSignature", "decode"}).count(member)) { // no-op } diff --git a/test/libsolidity/semanticTests/specialFunctions/abi_encode_decode_member_access.sol b/test/libsolidity/semanticTests/specialFunctions/abi_functions_member_access.sol similarity index 54% rename from test/libsolidity/semanticTests/specialFunctions/abi_encode_decode_member_access.sol rename to test/libsolidity/semanticTests/specialFunctions/abi_functions_member_access.sol index 0c5bbd9e2..b255b1880 100644 --- a/test/libsolidity/semanticTests/specialFunctions/abi_encode_decode_member_access.sol +++ b/test/libsolidity/semanticTests/specialFunctions/abi_functions_member_access.sol @@ -1,6 +1,9 @@ contract C { function f() public pure { abi.encode; + abi.encodePacked; + abi.encodeWithSelector; + abi.encodeWithSignature; abi.decode; } } diff --git a/test/libsolidity/syntaxTests/specialFunctions/abi_functions_member_access.sol b/test/libsolidity/syntaxTests/specialFunctions/abi_functions_member_access.sol new file mode 100644 index 000000000..c1f653794 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/abi_functions_member_access.sol @@ -0,0 +1,15 @@ +contract C { + function f() public pure { + abi.encode; + abi.encodePacked; + abi.encodeWithSelector; + abi.encodeWithSignature; + abi.decode; + } +} +// ---- +// Warning: (52-62): Statement has no effect. +// Warning: (72-88): Statement has no effect. +// Warning: (98-120): Statement has no effect. +// Warning: (130-153): Statement has no effect. +// Warning: (163-173): Statement has no effect.