From be4ec06f4b8664d05a6ab2d132ec9c2d1c3d24de Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Sun, 18 Aug 2013 20:09:54 -0400 Subject: [PATCH] Bug 414279 - Derived class method that overrides a base class method brought into the derived scope with a using-declaration Change-Id: Ibeb49dddb7ef3768ffd4964e22a139afba8690fb Signed-off-by: Nathan Ridge Reviewed-on: https://git.eclipse.org/r/15573 Reviewed-by: Sergey Prigogin IP-Clean: Sergey Prigogin Tested-by: Sergey Prigogin --- ...AbstractClassInstantiationCheckerTest.java | 19 +++++++++++++++++++ .../dom/parser/cpp/semantics/CPPVisitor.java | 10 +++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/AbstractClassInstantiationCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/AbstractClassInstantiationCheckerTest.java index df33e42fd17..c9bd97f9f2d 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/AbstractClassInstantiationCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/AbstractClassInstantiationCheckerTest.java @@ -312,4 +312,23 @@ public class AbstractClassInstantiationCheckerTest extends CheckerTestCase { loadCodeAndRun(getAboveComment()); checkErrorLine(13); } + + // struct A { + // virtual void test(int) = 0; + // virtual ~A(); + // }; + // + // struct B : public A { + // using A::test; + // void test(const char*); + // void test(int); + // }; + // + // int main() { + // B c; + // } + public void testUsingDeclarationInDerivedClass_bug414279() { + loadCodeAndRun(getAboveComment()); + checkNoErrors(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index c5a2c471daa..9fb71d60e3f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -848,7 +848,15 @@ public class CPPVisitor extends ASTQueries { if (isFunction) { if (binding instanceof ICPPInternalBinding && binding instanceof ICPPFunction && name.isActive()) { ICPPFunction function = (ICPPFunction) binding; - if (CPPSemantics.isSameFunction(function, typeRelevantDtor)) { + boolean sameFunction = CPPSemantics.isSameFunction(function, typeRelevantDtor); + if (function.getOwner() instanceof ICPPClassType) { + // Don't consider a function brought into scope from a base class scope + // to be the same as a function declared in a derived class scope. + if (!((ICPPClassType) function.getOwner()).getCompositeScope().equals(scope)) { + sameFunction = false; + } + } + if (sameFunction) { binding= CPPSemantics.checkDeclSpecifier(binding, name, parent); if (binding instanceof IProblemBinding) return binding;