diff options
author | chriseth <chris@ethereum.org> | 2017-07-06 03:14:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-06 03:14:06 +0800 |
commit | 4bde6fa96122a308296e00dfb32da25905c5ef34 (patch) | |
tree | 78ca85f3fa9834cdd54ad77449704337603b500f /test/libsolidity | |
parent | 2dd9070a4f8426fb16a4d611f21ed0f98f670195 (diff) | |
parent | dd34277ca60fcd9803a6fbb5a5944a1ed2533c73 (diff) | |
download | dexon-solidity-4bde6fa96122a308296e00dfb32da25905c5ef34.tar.gz dexon-solidity-4bde6fa96122a308296e00dfb32da25905c5ef34.tar.zst dexon-solidity-4bde6fa96122a308296e00dfb32da25905c5ef34.zip |
Merge pull request #2528 from ethereum/warnNoStorage
Warn if local storage reference variable does not use "storage" explicitly.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index d0aee3d0..e04d50e8 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2817,7 +2817,7 @@ BOOST_AUTO_TEST_CASE(uninitialized_mapping_array_variable) char const* sourceCode = R"( contract C { function f() { - mapping(uint => uint)[] x; + mapping(uint => uint)[] storage x; x; } } @@ -3103,7 +3103,7 @@ BOOST_AUTO_TEST_CASE(non_initialized_references) } function f() { - s x; + s storage x; x.a = 2; } } @@ -6144,6 +6144,32 @@ BOOST_AUTO_TEST_CASE(shadowing_warning_can_be_removed) CHECK_SUCCESS_NO_WARNINGS(text); } +BOOST_AUTO_TEST_CASE(warn_unspecified_storage) +{ + char const* text = R"( + contract C { + struct S { uint a; } + S x; + function f() { + S storage y = x; + y; + } + } + )"; + CHECK_SUCCESS_NO_WARNINGS(text); + text = R"( + contract C { + struct S { uint a; } + S x; + function f() { + S y = x; + y; + } + } + )"; + CHECK_WARNING(text, "is declared as a storage pointer. Use an explicit \"storage\" keyword to silence this warning"); +} + BOOST_AUTO_TEST_SUITE_END() |