aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-08-04 20:43:15 +0800
committerGitHub <noreply@github.com>2017-08-04 20:43:15 +0800
commit38e9505a83ed9b37ce91b8cd1ec268fc96be50cc (patch)
treec63973bc6d009a2a701a1e4cc9760a63fbfb9e20
parente48730fed95d6b6cc8a8b46f6b96d309526baea9 (diff)
parentb7642dc8a7ef54abf6f37fddefc118ca1108b0ae (diff)
downloaddexon-solidity-38e9505a83ed9b37ce91b8cd1ec268fc96be50cc.tar
dexon-solidity-38e9505a83ed9b37ce91b8cd1ec268fc96be50cc.tar.gz
dexon-solidity-38e9505a83ed9b37ce91b8cd1ec268fc96be50cc.tar.bz2
dexon-solidity-38e9505a83ed9b37ce91b8cd1ec268fc96be50cc.tar.lz
dexon-solidity-38e9505a83ed9b37ce91b8cd1ec268fc96be50cc.tar.xz
dexon-solidity-38e9505a83ed9b37ce91b8cd1ec268fc96be50cc.tar.zst
dexon-solidity-38e9505a83ed9b37ce91b8cd1ec268fc96be50cc.zip
Merge pull request #2673 from ethereum/builtin-gas
Disallow gas modifier on sha256/ripemd160/ecrecover
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/ast/Types.cpp3
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp15
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp24
4 files changed, 25 insertions, 18 deletions
diff --git a/Changelog.md b/Changelog.md
index 4b3f2ddc..86cf1058 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -5,6 +5,7 @@ Features:
Bugfixes:
* Code Generator: ``.delegatecall()`` should always return execution outcome.
* Code Generator: Provide "new account gas" for low-level ``callcode`` and ``delegatecall``.
+ * Type Checker: Disallow the ``.gas()`` modifier on ``ecrecover``, ``sha256`` and ``ripemd160``.
### 0.4.14 (2017-07-31)
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 3712eb15..56fdd508 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -2402,9 +2402,6 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con
{
case Kind::External:
case Kind::Creation:
- case Kind::ECRecover:
- case Kind::SHA256:
- case Kind::RIPEMD160:
case Kind::BareCall:
case Kind::BareCallCode:
case Kind::BareDelegateCall:
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index e6c816f4..d0c5285c 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2399,21 +2399,6 @@ BOOST_AUTO_TEST_CASE(gas_and_value_basic)
BOOST_REQUIRE(callContractFunction("checkState()") == encodeArgs(false, 20 - 5));
}
-BOOST_AUTO_TEST_CASE(gas_for_builtin)
-{
- char const* sourceCode = R"(
- contract Contract {
- function test(uint g) returns (bytes32 data, bool flag) {
- data = ripemd160.gas(g)("abc");
- flag = true;
- }
- }
- )";
- compileAndRun(sourceCode);
- BOOST_CHECK(callContractFunction("test(uint256)", 500) == bytes());
- BOOST_CHECK(callContractFunction("test(uint256)", 800) == encodeArgs(u256("0x8eb208f7e05d987a9b044a8e98c6b087f15a0bfc000000000000000000000000"), true));
-}
-
BOOST_AUTO_TEST_CASE(value_complex)
{
char const* sourceCode = R"(
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index e2e9f08a..4fe52243 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -6461,6 +6461,30 @@ BOOST_AUTO_TEST_CASE(builtin_reject_gas)
}
)";
CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup");
+ text = R"(
+ contract C {
+ function f() {
+ sha256.gas();
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup");
+ text = R"(
+ contract C {
+ function f() {
+ ripemd160.gas();
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup");
+ text = R"(
+ contract C {
+ function f() {
+ ecrecover.gas();
+ }
+ }
+ )";
+ CHECK_ERROR(text, TypeError, "Member \"gas\" not found or not visible after argument-dependent lookup");
}
BOOST_AUTO_TEST_CASE(builtin_reject_value)