aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-03-30 19:58:35 +0800
committerGitHub <noreply@github.com>2018-03-30 19:58:35 +0800
commit326d656a552ca247b5c96f1921c9c4c828ce93ad (patch)
tree0d03f9f5a347a051757e1d35f182eff782228e05 /libsolidity
parent58c57e446b65b31d8c4573d506c879fe385a51d7 (diff)
parentebb12756adfe95ae694ed7e141890c6d47e8b7b4 (diff)
downloaddexon-solidity-326d656a552ca247b5c96f1921c9c4c828ce93ad.tar
dexon-solidity-326d656a552ca247b5c96f1921c9c4c828ce93ad.tar.gz
dexon-solidity-326d656a552ca247b5c96f1921c9c4c828ce93ad.tar.bz2
dexon-solidity-326d656a552ca247b5c96f1921c9c4c828ce93ad.tar.lz
dexon-solidity-326d656a552ca247b5c96f1921c9c4c828ce93ad.tar.xz
dexon-solidity-326d656a552ca247b5c96f1921c9c4c828ce93ad.tar.zst
dexon-solidity-326d656a552ca247b5c96f1921c9c4c828ce93ad.zip
Merge pull request #3790 from ethereum/empty-structs
Disallow empty structs
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp14
-rw-r--r--libsolidity/analysis/SyntaxChecker.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index ddac194b..3a32810b 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -255,3 +255,17 @@ bool SyntaxChecker::visit(VariableDeclaration const& _declaration)
}
return true;
}
+
+bool SyntaxChecker::visit(StructDefinition const& _struct)
+{
+ bool const v050 = m_sourceUnit->annotation().experimentalFeatures.count(ExperimentalFeature::V050);
+
+ if (_struct.members().empty())
+ {
+ if (v050)
+ m_errorReporter.syntaxError(_struct.location(), "Defining empty structs is disallowed.");
+ else
+ m_errorReporter.warning(_struct.location(), "Defining empty structs is deprecated.");
+ }
+ 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 '_'.