aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-03-27 21:38:28 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-03-27 22:49:41 +0800
commitb540ba527a70df440299de9c0bf44f9d11ac6ef6 (patch)
treee9a57df2cabfc118ba92f671d66f430c1936ec2c /libsolidity
parent62559cf1278afc417d19ec181e2bced364cadea2 (diff)
downloaddexon-solidity-b540ba527a70df440299de9c0bf44f9d11ac6ef6.tar.gz
dexon-solidity-b540ba527a70df440299de9c0bf44f9d11ac6ef6.tar.zst
dexon-solidity-b540ba527a70df440299de9c0bf44f9d11ac6ef6.zip
Disallow empty structs
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp7
-rw-r--r--libsolidity/analysis/SyntaxChecker.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index ddac194b..e03417a9 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -255,3 +255,10 @@ bool SyntaxChecker::visit(VariableDeclaration const& _declaration)
}
return true;
}
+
+bool SyntaxChecker::visit(StructDefinition const& _struct)
+{
+ if (_struct.members().empty())
+ m_errorReporter.syntaxError(_struct.location(), "Defining empty structs is disallowed.");
+ return true;
+}
diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h
index 871bf0a9..1579df57 100644
--- a/libsolidity/analysis/SyntaxChecker.h
+++ b/libsolidity/analysis/SyntaxChecker.h
@@ -71,6 +71,8 @@ private:
virtual bool visit(VariableDeclaration const& _declaration) override;
+ virtual bool visit(StructDefinition const& _struct) override;
+
ErrorReporter& m_errorReporter;
/// Flag that indicates whether a function modifier actually contains '_'.