Skip to content

Commit

Permalink
Generalize the warning
Browse files Browse the repository at this point in the history
  • Loading branch information
pirapira committed Jun 9, 2017
1 parent 6545b4f commit 6231916
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions libsolidity/analysis/NameAndTypeResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <libsolidity/analysis/TypeChecker.h>
#include <libsolidity/interface/ErrorReporter.h>

#include <boost/algorithm/string.hpp>

using namespace std;

namespace dev
Expand Down Expand Up @@ -234,14 +236,19 @@ vector<Declaration const*> NameAndTypeResolver::cleanedDeclarations(

void NameAndTypeResolver::warnVariablesNamedLikeInstructions(void)
{
auto declarations = nameFromCurrentScope("returndatasize");
for (Declaration const* const declaration : declarations)
for (auto const& instruction : c_instructions)
{
solAssert(!!declaration, "");
m_errorReporter.warning(
declaration->location(),
"Variable is shadowed in an inline assembly by an insturction of the same name"
);
string instructionName{instruction.first}; // needs to copy because making it lower case.
boost::algorithm::to_lower(instructionName);
auto declarations = nameFromCurrentScope(instructionName);
for (Declaration const* const declaration : declarations)
{
solAssert(!!declaration, "");
m_errorReporter.warning(
declaration->location(),
"Variable is shadowed in an inline assembly by an insturction of the same name"
);
}
}
}

Expand Down

0 comments on commit 6231916

Please sign in to comment.