mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Warn about callcode.
This commit is contained in:
parent
735c977db1
commit
044058276e
@ -16,6 +16,7 @@ Features:
|
|||||||
* Code Generator: Added the Whiskers template system.
|
* Code Generator: Added the Whiskers template system.
|
||||||
* Remove obsolete Why3 output.
|
* Remove obsolete Why3 output.
|
||||||
* Type Checker: Enforce strict UTF-8 validation.
|
* Type Checker: Enforce strict UTF-8 validation.
|
||||||
|
* Static Analyzer: Warn about deprecation of ``callcode``.
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
* Code generator: Use ``REVERT`` instead of ``INVALID`` for generated input validation routines.
|
* Code generator: Use ``REVERT`` instead of ``INVALID`` for generated input validation routines.
|
||||||
|
@ -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?"
|
"\"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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)
|
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");
|
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)
|
BOOST_AUTO_TEST_CASE(modifier_without_underscore)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user