summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-07-21 21:40:00 (EDT)
committer Sergey Prigogin2013-07-24 13:56:16 (EDT)
commitec6fb10d7ab747d2866082f076d24d2c964f3687 (patch)
treeee9d7dffce40060982ac01558ee8cf3d6906d803
parent2accba3b07e0a9bf177431521ca4ce442609c6e0 (diff)
downloadorg.eclipse.cdt-ec6fb10d7ab747d2866082f076d24d2c964f3687.zip
org.eclipse.cdt-ec6fb10d7ab747d2866082f076d24d2c964f3687.tar.gz
org.eclipse.cdt-ec6fb10d7ab747d2866082f076d24d2c964f3687.tar.bz2
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 06c8a70..86b1aaf 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 0d40d06..93d3cee 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();
+ }
}