diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-07-01 03:39:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-01 03:39:20 +0800 |
commit | 95f790295564997705f455e3ed18b6c51546a847 (patch) | |
tree | f11230de1e0a8fc9da03b6d65f0c94bc21a0d2ea | |
parent | 4ca3b07e42ba6bb45c290aed7b6087c57f2cb242 (diff) | |
parent | 044058276ea27b3d43622b28416ad4dc41091a31 (diff) | |
download | dexon-solidity-95f790295564997705f455e3ed18b6c51546a847.tar dexon-solidity-95f790295564997705f455e3ed18b6c51546a847.tar.gz dexon-solidity-95f790295564997705f455e3ed18b6c51546a847.tar.bz2 dexon-solidity-95f790295564997705f455e3ed18b6c51546a847.tar.lz dexon-solidity-95f790295564997705f455e3ed18b6c51546a847.tar.xz dexon-solidity-95f790295564997705f455e3ed18b6c51546a847.tar.zst dexon-solidity-95f790295564997705f455e3ed18b6c51546a847.zip |
Merge pull request #2491 from ethereum/warnAboutCallcode
Warn about callcode.
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | libsolidity/analysis/StaticAnalyzer.cpp | 8 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 27 |
3 files changed, 35 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md index 8b44934d..4f224d5b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -16,6 +16,7 @@ Features: * Code Generator: Added the Whiskers template system. * Remove obsolete Why3 output. * Type Checker: Enforce strict UTF-8 validation. + * Static Analyzer: Warn about deprecation of ``callcode``. Bugfixes: * Code generator: Use ``REVERT`` instead of ``INVALID`` for generated input validation routines. diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index 375e9bde..b1b31163 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -123,6 +123,14 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess) "\"msg.value\" used in non-payable function. Do you want to add the \"payable\" modifier to this function?" ); + if (_memberAccess.memberName() == "callcode") + if (auto const* type = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type.get())) + if (type->kind() == FunctionType::Kind::BareCallCode) + m_errorReporter.warning( + _memberAccess.location(), + "\"callcode\" has been deprecated in favour of \"delegatecall\"." + ); + return true; } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 169b33d1..d0aee3d0 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -4679,7 +4679,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_callcode) } } )"; - CHECK_WARNING(text, "Return value of low-level calls not used"); + CHECK_WARNING_ALLOW_MULTI(text, "Return value of low-level calls not used"); } BOOST_AUTO_TEST_CASE(unused_return_value_delegatecall) @@ -4694,6 +4694,31 @@ BOOST_AUTO_TEST_CASE(unused_return_value_delegatecall) CHECK_WARNING(text, "Return value of low-level calls not used"); } +BOOST_AUTO_TEST_CASE(warn_about_callcode) +{ + char const* text = R"( + contract test { + function f() { + var x = address(0x12).callcode; + x; + } + } + )"; + CHECK_WARNING(text, "\"callcode\" has been deprecated in favour"); +} + +BOOST_AUTO_TEST_CASE(no_warn_about_callcode_as_local) +{ + char const* text = R"( + contract test { + function callcode() { + var x = this.callcode; + } + } + )"; + CHECK_SUCCESS_NO_WARNINGS(text); +} + BOOST_AUTO_TEST_CASE(modifier_without_underscore) { char const* text = R"( |