aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-04-25 19:15:42 +0800
committerchriseth <chris@ethereum.org>2017-04-25 22:49:04 +0800
commit1d712c7d6490616846de4ec9569ca627e62ea2c1 (patch)
treef3036aaab6076f6248148db9be9f92aa540055ac /libsolidity
parente841b23bfd57607511d620ed34ef96188bbadec6 (diff)
downloaddexon-solidity-1d712c7d6490616846de4ec9569ca627e62ea2c1.tar.gz
dexon-solidity-1d712c7d6490616846de4ec9569ca627e62ea2c1.tar.zst
dexon-solidity-1d712c7d6490616846de4ec9569ca627e62ea2c1.zip
Fix storage access tests.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp10
-rw-r--r--libsolidity/inlineasm/AsmAnalysis.cpp26
2 files changed, 21 insertions, 15 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index b07dbde1..08a49f51 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -655,6 +655,11 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
return size_t(-1);
}
}
+ else if (var->isConstant())
+ {
+ typeError(_identifier.location, "Constant variables not supported by inline assembly.");
+ return size_t(-1);
+ }
else if (!var->isLocalVariable())
{
typeError(_identifier.location, "Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.");
@@ -670,11 +675,6 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
typeError(_identifier.location, "Only types that use one stack slot are supported.");
return size_t(-1);
}
- else if (var->isConstant())
- {
- typeError(_identifier.location, "Constant variables not supported by inline assembly.");
- return size_t(-1);
- }
}
else if (_context == assembly::IdentifierContext::LValue)
{
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp
index 80cabe2e..97ec8b1f 100644
--- a/libsolidity/inlineasm/AsmAnalysis.cpp
+++ b/libsolidity/inlineasm/AsmAnalysis.cpp
@@ -79,6 +79,7 @@ bool AsmAnalyzer::operator()(assembly::Literal const& _literal)
bool AsmAnalyzer::operator()(assembly::Identifier const& _identifier)
{
+ size_t numErrorsBefore = m_errors.size();
bool success = true;
if (m_currentScope->lookup(_identifier.name, Scope::Visitor(
[&](Scope::Variable const& _var)
@@ -117,11 +118,13 @@ bool AsmAnalyzer::operator()(assembly::Identifier const& _identifier)
stackSize = m_resolver(_identifier, IdentifierContext::RValue);
if (stackSize == size_t(-1))
{
- m_errors.push_back(make_shared<Error>(
- Error::Type::DeclarationError,
- "Identifier not found.",
- _identifier.location
- ));
+ // Only add an error message if the callback did not do it.
+ if (numErrorsBefore == m_errors.size())
+ m_errors.push_back(make_shared<Error>(
+ Error::Type::DeclarationError,
+ "Identifier not found.",
+ _identifier.location
+ ));
success = false;
}
m_stackHeight += stackSize == size_t(-1) ? 1 : stackSize;
@@ -292,6 +295,7 @@ bool AsmAnalyzer::operator()(Block const& _block)
bool AsmAnalyzer::checkAssignment(assembly::Identifier const& _variable, size_t _valueSize)
{
bool success = true;
+ size_t numErrorsBefore = m_errors.size();
size_t variableSize(-1);
if (Scope::Identifier const* var = m_currentScope->lookup(_variable.name))
{
@@ -320,11 +324,13 @@ bool AsmAnalyzer::checkAssignment(assembly::Identifier const& _variable, size_t
variableSize = m_resolver(_variable, IdentifierContext::LValue);
if (variableSize == size_t(-1))
{
- m_errors.push_back(make_shared<Error>(
- Error::Type::DeclarationError,
- "Variable not found or variable not lvalue.",
- _variable.location
- ));
+ // Only add message if the callback did not.
+ if (numErrorsBefore == m_errors.size())
+ m_errors.push_back(make_shared<Error>(
+ Error::Type::DeclarationError,
+ "Variable not found or variable not lvalue.",
+ _variable.location
+ ));
success = false;
}
if (_valueSize == size_t(-1))