Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-07-22 01:40:00 +0000
committerSergey Prigogin2013-07-24 17:56:16 +0000
commitec6fb10d7ab747d2866082f076d24d2c964f3687 (patch)
treeee9d7dffce40060982ac01558ee8cf3d6906d803
parent2accba3b07e0a9bf177431521ca4ce442609c6e0 (diff)
downloadorg.eclipse.cdt-ec6fb10d7ab747d2866082f076d24d2c964f3687.tar.gz
org.eclipse.cdt-ec6fb10d7ab747d2866082f076d24d2c964f3687.tar.xz
org.eclipse.cdt-ec6fb10d7ab747d2866082f076d24d2c964f3687.zip
Bug 413406 - [false negative] Ambiguous base class lookup
Change-Id: I9f81619eb40456529fbfe4ce42ced661b9f1dac2 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/14728 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--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java19
2 files changed, 38 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
index 06c8a7095f2..86b1aafa0a9 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
@@ -2364,4 +2364,23 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testNPE_407497() throws Exception {
checkBindings();
}
+
+ // template <typename>
+ // struct basic_A {
+ // bool eof() const;
+ // };
+ //
+ // typedef basic_A<char> A;
+
+ // class B : public A {};
+ //
+ // class C : public A, public B {};
+ //
+ // void foo() {
+ // C c;
+ // c.eof();
+ // }
+ public void testAmbiguousBaseClassLookup_413406() throws Exception {
+ getProblemFromASTName("eof();", 3);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java
index 0d40d06d37f..93d3cee4801 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java
@@ -275,4 +275,23 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
public EScopeKind getKind() {
return EScopeKind.eClassType;
}
+
+ // Note: equals() and hashCode() are overridden because multiple instances
+ // of this class representing the same class specialization scope
+ // may be created, but scopes are sometimes stored in hash maps
+ // under the assumption that two objects representing the same
+ // scope will compare equal().
+
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof ICPPClassSpecializationScope) {
+ return getClassType().equals(((ICPPClassSpecializationScope) other).getClassType());
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return specialClass.hashCode();
+ }
}

Back to the top