aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-06-22 01:32:56 +0800
committerchriseth <chris@ethereum.org>2017-06-26 22:31:36 +0800
commitd0b6de0b346b319c85747fdbee76c1d204d6ced6 (patch)
treec1c58441ee94e082c753ce5727d79fd61d28e504 /test/libsolidity
parent751ba701bca0fbcae6d74cfdc23a4ac4a1c3dfab (diff)
downloaddexon-solidity-d0b6de0b346b319c85747fdbee76c1d204d6ced6.tar
dexon-solidity-d0b6de0b346b319c85747fdbee76c1d204d6ced6.tar.gz
dexon-solidity-d0b6de0b346b319c85747fdbee76c1d204d6ced6.tar.bz2
dexon-solidity-d0b6de0b346b319c85747fdbee76c1d204d6ced6.tar.lz
dexon-solidity-d0b6de0b346b319c85747fdbee76c1d204d6ced6.tar.xz
dexon-solidity-d0b6de0b346b319c85747fdbee76c1d204d6ced6.tar.zst
dexon-solidity-d0b6de0b346b319c85747fdbee76c1d204d6ced6.zip
Warn about copies in storage that might overwrite unexpectedly.
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index a6027812..6af5f503 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -5771,6 +5771,48 @@ BOOST_AUTO_TEST_CASE(pure_statement_check_for_regular_for_loop)
success(text);
}
+BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies)
+{
+ char const* text = R"(
+ contract C {
+ struct S { uint a; uint b; }
+ S x; S y;
+ function f() {
+ (x, y) = (y, x);
+ }
+ }
+ )";
+ CHECK_WARNING(text, "This assignment performs two copies to storage.");
+}
+
+BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies_fill_right)
+{
+ char const* text = R"(
+ contract C {
+ struct S { uint a; uint b; }
+ S x; S y;
+ function f() {
+ (x, y, ) = (y, x, 1, 2);
+ }
+ }
+ )";
+ CHECK_WARNING(text, "This assignment performs two copies to storage.");
+}
+
+BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies_fill_left)
+{
+ char const* text = R"(
+ contract C {
+ struct S { uint a; uint b; }
+ S x; S y;
+ function f() {
+ (,x, y) = (1, 2, y, x);
+ }
+ }
+ )";
+ CHECK_WARNING(text, "This assignment performs two copies to storage.");
+}
+
BOOST_AUTO_TEST_CASE(warn_unused_local)
{
char const* text = R"(