From 08015590f23957153e12f06a2bcba6e9246733bc Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Tue, 18 Oct 2016 14:52:27 +0200 Subject: analysis: Allow multiple events of the same name Fixes #1215 --- libsolidity/analysis/DeclarationContainer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libsolidity/analysis') diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index f8c12c5b..ac80ab18 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -58,6 +58,13 @@ Declaration const* DeclarationContainer::conflictingDeclaration( return declaration; } } + else if (dynamic_cast(&_declaration)) + { + // check that all other declarations with the same name are events + for (Declaration const* declaration: declarations) + if (!dynamic_cast(declaration)) + return declaration; + } else if (declarations.size() == 1 && declarations.front() == &_declaration) return nullptr; else if (!declarations.empty()) -- cgit From 846f7dc3ea6591b34deb3e6738292ffd87c06ed3 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Thu, 20 Oct 2016 10:47:15 +0200 Subject: analysis: Resolve event overloading --- libsolidity/analysis/DeclarationContainer.cpp | 21 +++++++++------------ libsolidity/analysis/NameAndTypeResolver.cpp | 4 ++-- 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'libsolidity/analysis') diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index ac80ab18..04836603 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -42,28 +42,25 @@ Declaration const* DeclarationContainer::conflictingDeclaration( if (m_invisibleDeclarations.count(*_name)) declarations += m_invisibleDeclarations.at(*_name); - if (dynamic_cast(&_declaration)) + if (dynamic_cast(&_declaration) || + dynamic_cast(&_declaration) + ) { - // check that all other declarations with the same name are functions or a public state variable + // check that all other declarations with the same name are functions or a public state variable or events. + // And then check that the signatures are different. for (Declaration const* declaration: declarations) { - if (dynamic_cast(declaration)) - continue; if (auto variableDeclaration = dynamic_cast(declaration)) { if (variableDeclaration->isStateVariable() && !variableDeclaration->isConstant() && variableDeclaration->isPublic()) continue; return declaration; } - return declaration; - } - } - else if (dynamic_cast(&_declaration)) - { - // check that all other declarations with the same name are events - for (Declaration const* declaration: declarations) - if (!dynamic_cast(declaration)) + if (!dynamic_cast(declaration) && + !dynamic_cast(declaration)) return declaration; + // Or, continue. + } } else if (declarations.size() == 1 && declarations.front() == &_declaration) return nullptr; diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 08323243..b0a82715 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -260,8 +260,8 @@ vector NameAndTypeResolver::cleanedDeclarations( for (auto it = _declarations.begin(); it != _declarations.end(); ++it) { solAssert(*it, ""); - // the declaration is functionDefinition or a VariableDeclaration while declarations > 1 - solAssert(dynamic_cast(*it) || dynamic_cast(*it), + // the declaration is functionDefinition, eventDefinition or a VariableDeclaration while declarations > 1 + solAssert(dynamic_cast(*it) || dynamic_cast(*it) || dynamic_cast(*it), "Found overloading involving something not a function or a variable"); shared_ptr functionType { (*it)->functionType(false) }; -- cgit From 399b7b695a2ffe5ae2b07628860712fc76dfe03c Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Mon, 23 Jan 2017 14:51:17 +0100 Subject: analysis: fix format --- libsolidity/analysis/DeclarationContainer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'libsolidity/analysis') diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index 04836603..7e8cd2ca 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -42,9 +42,10 @@ Declaration const* DeclarationContainer::conflictingDeclaration( if (m_invisibleDeclarations.count(*_name)) declarations += m_invisibleDeclarations.at(*_name); - if (dynamic_cast(&_declaration) || + if ( + dynamic_cast(&_declaration) || dynamic_cast(&_declaration) - ) + ) { // check that all other declarations with the same name are functions or a public state variable or events. // And then check that the signatures are different. @@ -56,8 +57,10 @@ Declaration const* DeclarationContainer::conflictingDeclaration( continue; return declaration; } - if (!dynamic_cast(declaration) && - !dynamic_cast(declaration)) + if ( + !dynamic_cast(declaration) && + !dynamic_cast(declaration) + ) return declaration; // Or, continue. } -- cgit From 4e1fd68b38346ec3e4117dc0454b65f4b236741b Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Mon, 23 Jan 2017 15:24:47 +0100 Subject: analysis: disallow overloading functions with events --- libsolidity/analysis/DeclarationContainer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libsolidity/analysis') diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index 7e8cd2ca..b33c8568 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -58,7 +58,12 @@ Declaration const* DeclarationContainer::conflictingDeclaration( return declaration; } if ( - !dynamic_cast(declaration) && + dynamic_cast(&_declaration) && + !dynamic_cast(declaration) + ) + return declaration; + if ( + dynamic_cast(&_declaration) && !dynamic_cast(declaration) ) return declaration; -- cgit