mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow raw callcode (was deprecated in 0.4.12)
This commit is contained in:
parent
4189b6b03d
commit
a17059573f
@ -8,6 +8,7 @@ Breaking Changes:
|
|||||||
* Commandline interface: Require ``-`` if standard input is used as source.
|
* Commandline interface: Require ``-`` if standard input is used as source.
|
||||||
* General: ``continue`` in a ``do...while`` loop jumps to the condition (it used to jump to the loop body). Warning: this may silently change the semantics of existing code.
|
* General: ``continue`` in a ``do...while`` loop jumps to the condition (it used to jump to the loop body). Warning: this may silently change the semantics of existing code.
|
||||||
* General: Disallow declaring empty structs.
|
* General: Disallow declaring empty structs.
|
||||||
|
* General: Disallow raw ``callcode`` (was already deprecated in 0.4.12). It is still possible to use it via inline assembly.
|
||||||
* General: Disallow ``sha3`` and ``suicide`` aliases.
|
* General: Disallow ``sha3`` and ``suicide`` aliases.
|
||||||
* General: Introduce ``emit`` as a keyword instead of parsing it as identifier.
|
* General: Introduce ``emit`` as a keyword instead of parsing it as identifier.
|
||||||
* General: New keywords: ``calldata``
|
* General: New keywords: ``calldata``
|
||||||
|
@ -193,18 +193,10 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess)
|
|||||||
if (_memberAccess.memberName() == "callcode")
|
if (_memberAccess.memberName() == "callcode")
|
||||||
if (auto const* type = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type.get()))
|
if (auto const* type = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type.get()))
|
||||||
if (type->kind() == FunctionType::Kind::BareCallCode)
|
if (type->kind() == FunctionType::Kind::BareCallCode)
|
||||||
{
|
m_errorReporter.typeError(
|
||||||
if (v050)
|
_memberAccess.location(),
|
||||||
m_errorReporter.typeError(
|
"\"callcode\" has been deprecated in favour of \"delegatecall\"."
|
||||||
_memberAccess.location(),
|
);
|
||||||
"\"callcode\" has been deprecated in favour of \"delegatecall\"."
|
|
||||||
);
|
|
||||||
else
|
|
||||||
m_errorReporter.warning(
|
|
||||||
_memberAccess.location(),
|
|
||||||
"\"callcode\" has been deprecated in favour of \"delegatecall\"."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_constructor)
|
if (m_constructor)
|
||||||
{
|
{
|
||||||
|
@ -3745,38 +3745,6 @@ BOOST_AUTO_TEST_CASE(generic_call)
|
|||||||
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 50 - 2);
|
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 50 - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(generic_callcode)
|
|
||||||
{
|
|
||||||
char const* sourceCode = R"**(
|
|
||||||
contract Receiver {
|
|
||||||
uint public received;
|
|
||||||
function receive(uint256 x) payable { received = x; }
|
|
||||||
}
|
|
||||||
contract Sender {
|
|
||||||
uint public received;
|
|
||||||
function Sender() payable { }
|
|
||||||
function doSend(address rec) returns (uint d)
|
|
||||||
{
|
|
||||||
bytes4 signature = bytes4(bytes32(keccak256("receive(uint256)")));
|
|
||||||
rec.callcode.value(2)(signature, 23);
|
|
||||||
return Receiver(rec).received();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)**";
|
|
||||||
compileAndRun(sourceCode, 0, "Receiver");
|
|
||||||
u160 const c_receiverAddress = m_contractAddress;
|
|
||||||
compileAndRun(sourceCode, 50, "Sender");
|
|
||||||
u160 const c_senderAddress = m_contractAddress;
|
|
||||||
ABI_CHECK(callContractFunction("doSend(address)", c_receiverAddress), encodeArgs(0));
|
|
||||||
ABI_CHECK(callContractFunction("received()"), encodeArgs(23));
|
|
||||||
m_contractAddress = c_receiverAddress;
|
|
||||||
ABI_CHECK(callContractFunction("received()"), encodeArgs(0));
|
|
||||||
BOOST_CHECK(storageEmpty(c_receiverAddress));
|
|
||||||
BOOST_CHECK(!storageEmpty(c_senderAddress));
|
|
||||||
BOOST_CHECK_EQUAL(balanceAt(c_receiverAddress), 0);
|
|
||||||
BOOST_CHECK_EQUAL(balanceAt(c_senderAddress), 50);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(generic_delegatecall)
|
BOOST_AUTO_TEST_CASE(generic_delegatecall)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"**(
|
char const* sourceCode = R"**(
|
||||||
@ -11558,9 +11526,6 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address)
|
|||||||
function f() external returns (bool) {
|
function f() external returns (bool) {
|
||||||
return address(0x4242).call();
|
return address(0x4242).call();
|
||||||
}
|
}
|
||||||
function g() external returns (bool) {
|
|
||||||
return address(0x4242).callcode();
|
|
||||||
}
|
|
||||||
function h() external returns (bool) {
|
function h() external returns (bool) {
|
||||||
return address(0x4242).delegatecall();
|
return address(0x4242).delegatecall();
|
||||||
}
|
}
|
||||||
@ -11568,7 +11533,6 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address)
|
|||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode, 0, "C");
|
compileAndRun(sourceCode, 0, "C");
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1)));
|
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1)));
|
||||||
ABI_CHECK(callContractFunction("g()"), encodeArgs(u256(1)));
|
|
||||||
ABI_CHECK(callContractFunction("h()"), encodeArgs(u256(1)));
|
ABI_CHECK(callContractFunction("h()"), encodeArgs(u256(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
contract test {
|
|
||||||
function f() public {
|
|
||||||
address(0x12).callcode("abc");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ----
|
|
||||||
// Warning: (50-79): Return value of low-level calls not used.
|
|
||||||
// Warning: (50-72): "callcode" has been deprecated in favour of "delegatecall".
|
|
@ -4,4 +4,4 @@ contract test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (55-77): "callcode" has been deprecated in favour of "delegatecall".
|
// TypeError: (55-77): "callcode" has been deprecated in favour of "delegatecall".
|
||||||
|
@ -3,13 +3,10 @@ contract C {
|
|||||||
address addr;
|
address addr;
|
||||||
uint balance = addr.balance;
|
uint balance = addr.balance;
|
||||||
bool callRet = addr.call();
|
bool callRet = addr.call();
|
||||||
bool callcodeRet = addr.callcode();
|
|
||||||
bool delegatecallRet = addr.delegatecall();
|
bool delegatecallRet = addr.delegatecall();
|
||||||
bool sendRet = addr.send(1);
|
bool sendRet = addr.send(1);
|
||||||
addr.transfer(1);
|
addr.transfer(1);
|
||||||
callRet; callcodeRet; delegatecallRet; sendRet;
|
balance; callRet; delegatecallRet; sendRet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (161-174): "callcode" has been deprecated in favour of "delegatecall".
|
|
||||||
// Warning: (69-81): Unused local variable.
|
|
||||||
|
@ -5,4 +5,4 @@ contract C {
|
|||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (52-65): Using contract member "callcode" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).callcode" instead.
|
// Warning: (52-65): Using contract member "callcode" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).callcode" instead.
|
||||||
// Warning: (52-65): "callcode" has been deprecated in favour of "delegatecall".
|
// TypeError: (52-65): "callcode" has been deprecated in favour of "delegatecall".
|
||||||
|
@ -6,4 +6,4 @@ contract C {
|
|||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (65-75): Using contract member "callcode" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).callcode" instead.
|
// Warning: (65-75): Using contract member "callcode" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).callcode" instead.
|
||||||
// Warning: (65-75): "callcode" has been deprecated in favour of "delegatecall".
|
// TypeError: (65-75): "callcode" has been deprecated in favour of "delegatecall".
|
||||||
|
Loading…
Reference in New Issue
Block a user