aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2017-03-11 02:25:47 +0800
committerGitHub <noreply@github.com>2017-03-11 02:25:47 +0800
commitef8b56a05823e39ffc2577af653200f22d6b15a1 (patch)
tree507b8c8194e503b073bd3cf82de058b27f08b486 /test
parentf1dd79c7433a6c78e879a0b597b0585921838f1e (diff)
parent1324ebc4bf84438715744afb9bcf1469b8e00b05 (diff)
downloaddexon-solidity-ef8b56a05823e39ffc2577af653200f22d6b15a1.tar.gz
dexon-solidity-ef8b56a05823e39ffc2577af653200f22d6b15a1.tar.zst
dexon-solidity-ef8b56a05823e39ffc2577af653200f22d6b15a1.zip
Merge pull request #1751 from ethereum/warnLiteralExpBase
Warn if base of exponentiation operation is a literal.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index dda7105c..865fd0c5 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -1663,6 +1663,36 @@ BOOST_AUTO_TEST_CASE(exp_operator_exponent_too_big)
CHECK_ERROR(sourceCode, TypeError, "");
}
+BOOST_AUTO_TEST_CASE(exp_warn_literal_base)
+{
+ char const* sourceCode = R"(
+ contract test {
+ function f() returns(uint d) {
+ uint8 x = 100;
+ return 10**x;
+ }
+ }
+ )";
+ CHECK_WARNING(sourceCode, "might overflow");
+ sourceCode = R"(
+ contract test {
+ function f() returns(uint d) {
+ uint8 x = 100;
+ return uint8(10)**x;
+ }
+ }
+ )";
+ CHECK_SUCCESS(sourceCode);
+ sourceCode = R"(
+ contract test {
+ function f() returns(uint d) {
+ return 2**80;
+ }
+ }
+ )";
+ CHECK_SUCCESS(sourceCode);
+}
+
BOOST_AUTO_TEST_CASE(enum_member_access)
{
char const* text = R"(