aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-08-16 23:54:06 +0800
committerGitHub <noreply@github.com>2017-08-16 23:54:06 +0800
commit4449820be3b23cb074c8db77915a799b3ff31c49 (patch)
treeeb1cc0d4735e34f121684d6099f4f0c663b850ef /test/libsolidity
parent83561e136c992287211f348e0b7bd85b8087fe23 (diff)
parent3d595d4b149e590138f35a6f535c0a20a28e6f04 (diff)
downloaddexon-solidity-4449820be3b23cb074c8db77915a799b3ff31c49.tar.gz
dexon-solidity-4449820be3b23cb074c8db77915a799b3ff31c49.tar.zst
dexon-solidity-4449820be3b23cb074c8db77915a799b3ff31c49.zip
Merge pull request #2758 from ethereum/warnShift
Warn about shift of literals.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 51d60596..1c83e1a3 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -1765,6 +1765,44 @@ BOOST_AUTO_TEST_CASE(exp_warn_literal_base)
CHECK_SUCCESS(sourceCode);
}
+BOOST_AUTO_TEST_CASE(shift_warn_literal_base)
+{
+ char const* sourceCode = R"(
+ contract test {
+ function f() returns(uint) {
+ uint8 x = 100;
+ return 10 << x;
+ }
+ }
+ )";
+ CHECK_WARNING(sourceCode, "might overflow");
+ sourceCode = R"(
+ contract test {
+ function f() returns(uint) {
+ uint8 x = 100;
+ return uint8(10) << x;
+ }
+ }
+ )";
+ CHECK_SUCCESS(sourceCode);
+ sourceCode = R"(
+ contract test {
+ function f() returns(uint) {
+ return 2 << 80;
+ }
+ }
+ )";
+ CHECK_SUCCESS(sourceCode);
+ sourceCode = R"(
+ contract test {
+ function f() returns(uint) {
+ uint8 x = 100;
+ return 10 >> x;
+ }
+ }
+ )";
+ CHECK_SUCCESS(sourceCode);
+}
BOOST_AUTO_TEST_CASE(warn_var_from_zero)
{