aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-06-26 18:51:12 +0800
committerGitHub <noreply@github.com>2017-06-26 18:51:12 +0800
commita0b0df2d98f7d4c60fe9fb9e79739c0c09b94365 (patch)
treeb8e4cd938ada219278e3c0ea5509b4ef0a793bdd /libsolidity/analysis
parentc328ab411b63fe182125e976eb05b4449fdd892d (diff)
parent5a75581f6643a229ab12a861d0b0663ea3e5158e (diff)
downloaddexon-solidity-a0b0df2d98f7d4c60fe9fb9e79739c0c09b94365.tar.gz
dexon-solidity-a0b0df2d98f7d4c60fe9fb9e79739c0c09b94365.tar.zst
dexon-solidity-a0b0df2d98f7d4c60fe9fb9e79739c0c09b94365.zip
Merge pull request #2460 from ethereum/disallowMultiModifier
Disallow invoking the same modifier multiple times.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 615bc402..40ff59f6 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -467,13 +467,26 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
var->accept(*this);
}
+ set<Declaration const*> modifiers;
for (ASTPointer<ModifierInvocation> const& modifier: _function.modifiers())
+ {
visitManually(
*modifier,
_function.isConstructor() ?
dynamic_cast<ContractDefinition const&>(*_function.scope()).annotation().linearizedBaseContracts :
vector<ContractDefinition const*>()
);
+ Declaration const* decl = &dereference(*modifier->name());
+ if (modifiers.count(decl))
+ {
+ if (dynamic_cast<ContractDefinition const*>(decl))
+ m_errorReporter.declarationError(modifier->location(), "Base constructor already provided.");
+ else
+ m_errorReporter.declarationError(modifier->location(), "Modifier already used for this function.");
+ }
+ else
+ modifiers.insert(decl);
+ }
if (m_scope->contractKind() == ContractDefinition::ContractKind::Interface)
{
if (_function.isImplemented())