aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorFederico Bond <federicobond@gmail.com>2017-12-12 05:00:15 +0800
committerDaniel Kirchner <daniel@ekpyron.org>2018-04-09 17:22:35 +0800
commit4e037281acaf74c907f68e6227d6aa1b8847c78d (patch)
tree1317b5018a7b91d24578d16d1f6f6a2780c01771 /libsolidity/analysis
parentfe61435c273bf43ac1a20d8bc97b6935a54b7117 (diff)
downloaddexon-solidity-4e037281acaf74c907f68e6227d6aa1b8847c78d.tar.gz
dexon-solidity-4e037281acaf74c907f68e6227d6aa1b8847c78d.tar.zst
dexon-solidity-4e037281acaf74c907f68e6227d6aa1b8847c78d.zip
Error on duplicated super constructor calls
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/StaticAnalyzer.cpp32
-rw-r--r--libsolidity/analysis/StaticAnalyzer.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp
index 33b0e296..6c70ba6b 100644
--- a/libsolidity/analysis/StaticAnalyzer.cpp
+++ b/libsolidity/analysis/StaticAnalyzer.cpp
@@ -90,6 +90,38 @@ void StaticAnalyzer::endVisit(FunctionDefinition const&)
m_localVarUseCount.clear();
}
+bool modifierOverridesInheritanceSpecifier(
+ ContractDefinition const* _contract,
+ ModifierInvocation const& _modifier,
+ InheritanceSpecifier const& _specifier
+)
+{
+ auto parent = _specifier.name().annotation().referencedDeclaration;
+ return _contract == parent && (!_specifier.arguments().empty() || _modifier.arguments().empty());
+}
+
+bool StaticAnalyzer::visit(ModifierInvocation const& _modifier)
+{
+ if (!m_constructor)
+ return true;
+
+ if (auto contract = dynamic_cast<ContractDefinition const*>(_modifier.name()->annotation().referencedDeclaration))
+ for (auto const& specifier: m_currentContract->baseContracts())
+ if (modifierOverridesInheritanceSpecifier(contract, _modifier, *specifier))
+ {
+ SecondarySourceLocation ssl;
+ ssl.append("Overriden constructor call is here:", specifier->location());
+
+ m_errorReporter.declarationError(
+ _modifier.location(),
+ ssl,
+ "Duplicated super constructor call."
+ );
+ }
+
+ return true;
+}
+
bool StaticAnalyzer::visit(Identifier const& _identifier)
{
if (m_currentFunction)
diff --git a/libsolidity/analysis/StaticAnalyzer.h b/libsolidity/analysis/StaticAnalyzer.h
index 0a806bbd..e68325bc 100644
--- a/libsolidity/analysis/StaticAnalyzer.h
+++ b/libsolidity/analysis/StaticAnalyzer.h
@@ -57,6 +57,7 @@ private:
virtual bool visit(FunctionDefinition const& _function) override;
virtual void endVisit(FunctionDefinition const& _function) override;
+ virtual bool visit(ModifierInvocation const& _modifier) override;
virtual bool visit(ExpressionStatement const& _statement) override;
virtual bool visit(VariableDeclaration const& _variable) override;