mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Warn if local storage reference variable does not use "storage" explicitly.
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user