summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-08-18 20:09:54 (EDT)
committer Sergey Prigogin2013-08-18 21:42:34 (EDT)
commitbe4ec06f4b8664d05a6ab2d132ec9c2d1c3d24de (patch)
tree57dc64d6d202260222a4b5c0f8f2c352aee6d698
parente288c295968a5b75fdb303dd380c25579b69f214 (diff)
downloadorg.eclipse.cdt-be4ec06f4b8664d05a6ab2d132ec9c2d1c3d24de.zip
org.eclipse.cdt-be4ec06f4b8664d05a6ab2d132ec9c2d1c3d24de.tar.gz
org.eclipse.cdt-be4ec06f4b8664d05a6ab2d132ec9c2d1c3d24de.tar.bz2
Bug 414279 - Derived class method that overrides a base class methodrefs/changes/73/15573/2
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;