Merge pull request #3790 from ethereum/empty-structs

Disallow empty structs
This commit is contained in:
chriseth
2018-03-30 13:58:35 +02:00
committed by GitHub
7 changed files with 30 additions and 2 deletions
+14
View File
@@ -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;
}
+2
View File
@@ -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 '_'.