summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-08-18 20:09:54 (EDT)
committer Sergey Prigogin2013-08-19 16:59:42 (EDT)
commitb3b9eb576e7238a4a7e829b7f2cf34ae6848e693 (patch)
tree093a99a4cf46a70a6ba7af46d68bfdde59fb7579
parent2db05f1b64dc5e5832c21d8e3d18e749b19d93b7 (diff)
downloadorg.eclipse.cdt-b3b9eb576e7238a4a7e829b7f2cf34ae6848e693.zip
org.eclipse.cdt-b3b9eb576e7238a4a7e829b7f2cf34ae6848e693.tar.gz
org.eclipse.cdt-b3b9eb576e7238a4a7e829b7f2cf34ae6848e693.tar.bz2
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 <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/15573 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/AbstractClassInstantiationCheckerTest.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java10
2 files changed, 28 insertions, 1 deletions
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 df33e42..c9bd97f 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 c5a2c47..9fb71d6 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;