From dd34277ca60fcd9803a6fbb5a5944a1ed2533c73 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 5 Jul 2017 19:38:00 +0200 Subject: Warn if local storage reference variable does not use "storage" explicitly. --- libsolidity/analysis/ReferencesResolver.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libsolidity/analysis/ReferencesResolver.cpp') diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 2a5f27df..cc95c294 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -289,7 +289,20 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable) typeLoc = DataLocation::Memory; } else if (varLoc == Location::Default) - typeLoc = _variable.isCallableParameter() ? DataLocation::Memory : DataLocation::Storage; + { + if (_variable.isCallableParameter()) + typeLoc = DataLocation::Memory; + else + { + typeLoc = DataLocation::Storage; + if (!_variable.isStateVariable()) + m_errorReporter.warning( + _variable.location(), + "Variable is declared as a storage pointer. " + "Use an explicit \"storage\" keyword to silence this warning." + ); + } + } else typeLoc = varLoc == Location::Memory ? DataLocation::Memory : DataLocation::Storage; isPointer = !_variable.isStateVariable(); -- cgit