aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-20 02:21:33 +0800
committerchriseth <chris@ethereum.org>2018-02-20 02:22:39 +0800
commit930485cd244cc32fd499dc3d59f1220b972c9da1 (patch)
treebf992d938688967feffb94ba7e725b1ec55af659
parenta680cbd47411c20b8bda59b535fc138974e72f0d (diff)
downloaddexon-solidity-930485cd244cc32fd499dc3d59f1220b972c9da1.tar
dexon-solidity-930485cd244cc32fd499dc3d59f1220b972c9da1.tar.gz
dexon-solidity-930485cd244cc32fd499dc3d59f1220b972c9da1.tar.bz2
dexon-solidity-930485cd244cc32fd499dc3d59f1220b972c9da1.tar.lz
dexon-solidity-930485cd244cc32fd499dc3d59f1220b972c9da1.tar.xz
dexon-solidity-930485cd244cc32fd499dc3d59f1220b972c9da1.tar.zst
dexon-solidity-930485cd244cc32fd499dc3d59f1220b972c9da1.zip
Properly warn about the use of constants in inline assembly in connection with ``_offset`` and ``_slot``.
-rw-r--r--libsolidity/analysis/TypeChecker.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index f62ddeb9..0ee16c89 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -804,7 +804,12 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
solAssert(!!declaration, "");
if (auto var = dynamic_cast<VariableDeclaration const*>(declaration))
{
- if (ref->second.isSlot || ref->second.isOffset)
+ if (var->isConstant())
+ {
+ m_errorReporter.typeError(_identifier.location, "Constant variables not supported by inline assembly.");
+ return size_t(-1);
+ }
+ else if (ref->second.isSlot || ref->second.isOffset)
{
if (!var->isStateVariable() && !var->type()->dataStoredIn(DataLocation::Storage))
{
@@ -817,11 +822,6 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
return size_t(-1);
}
}
- else if (var->isConstant())
- {
- m_errorReporter.typeError(_identifier.location, "Constant variables not supported by inline assembly.");
- return size_t(-1);
- }
else if (!var->isLocalVariable())
{
m_errorReporter.typeError(_identifier.location, "Only local variables are supported. To access storage variables, use the _slot and _offset suffixes.");