aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-02-07 00:54:05 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-02-24 08:18:18 +0800
commit81006dae98ee18c33994af0274de10857774ff70 (patch)
treef12a3778dacf688b76df7ecabcc1ad24954e36aa
parentba437ef31a95f40f510a475e8b329f061e929b90 (diff)
downloaddexon-solidity-81006dae98ee18c33994af0274de10857774ff70.tar.gz
dexon-solidity-81006dae98ee18c33994af0274de10857774ff70.tar.zst
dexon-solidity-81006dae98ee18c33994af0274de10857774ff70.zip
Support gas modifier on addr.transfer()
-rw-r--r--libsolidity/ast/Types.cpp3
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp3
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp6
3 files changed, 10 insertions, 2 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 7fccccbc..3e3a3818 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -2315,9 +2315,10 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con
case Location::Bare:
case Location::BareCallCode:
case Location::BareDelegateCall:
+ case Location::Transfer:
{
MemberList::MemberMap members;
- if (m_location != Location::BareDelegateCall && m_location != Location::DelegateCall)
+ if (m_location != Location::BareDelegateCall && m_location != Location::DelegateCall && m_location != Location::Transfer)
{
if (m_isPayable)
members.push_back(MemberList::Member(
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index b0031513..92b91563 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -620,7 +620,8 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
_functionCall.expression().accept(*this);
// Provide the gas stipend manually at first because we may send zero ether.
// Will be zeroed if we send more than zero ether.
- m_context << u256(eth::GasCosts::callStipend);
+ if (!function.gasSet())
+ m_context << u256(eth::GasCosts::callStipend);
arguments.front()->accept(*this);
utils().convertType(
*arguments.front()->annotation().type,
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index cb0cc168..30430aef 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -1693,6 +1693,10 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
function b(address addr, uint amount) {
addr.transfer(amount);
}
+ function c(address addr, uint amount, uint gas) returns (uint) {
+ addr.transfer.gas(gas)(amount);
+ return this.balance;
+ }
}
contract B {
@@ -1715,6 +1719,8 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
BOOST_CHECK(callContractFunction("b(address,uint256)", nonPayableRecipient, 10) == encodeArgs());
BOOST_CHECK(callContractFunction("b(address,uint256)", oogRecipient, 10) == encodeArgs());
+ BOOST_CHECK(callContractFunction("c(address,uint256,uint256)", payableRecipient, 1, 9000) == encodeArgs(9));
+ BOOST_CHECK(callContractFunction("c(address,uint256,uint256)", payableRecipient, 1, 0) == encodeArgs());
}
BOOST_AUTO_TEST_CASE(log0)