Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSergey Prigogin2009-08-24 14:24:04 -0400
committerSergey Prigogin2009-08-24 14:24:04 -0400
commit0c3e40acba5603c236aa1a2fe66e644118abefbf (patch)
treeb1f1fb5f457e886bcc1a448d527b59b08998357a /core
parentcf0fd4a859000442fc58764ea8b1c1687607865d (diff)
downloadorg.eclipse.cdt-0c3e40acba5603c236aa1a2fe66e644118abefbf.tar.gz
org.eclipse.cdt-0c3e40acba5603c236aa1a2fe66e644118abefbf.tar.xz
org.eclipse.cdt-0c3e40acba5603c236aa1a2fe66e644118abefbf.zip
Bug 284665.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java30
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java8
3 files changed, 39 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
index 87dcc20d3b..0e5184d22e 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java
@@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
@@ -41,6 +42,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.core.runtime.CoreException;
/**
@@ -1358,6 +1360,32 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
}
// class A {
+ // class B;
+ // void method();
+ // };
+
+ // class A::B {
+ // B(int x);
+ // static void m(int p);
+ // };
+ //
+ // void A::method() {
+ // new B(0);
+ // B::m(0);
+ // }
+ public void testNestedClass_284665() throws Exception {
+ ICPPClassType b0 = getBindingFromASTName("B {", 1, ICPPClassType.class);
+ assertFalse(b0 instanceof IIndexBinding);
+ ICPPConstructor b1 = getBindingFromASTName("B(int x)", 1, ICPPConstructor.class);
+ assertFalse(b1 instanceof IIndexBinding);
+ ICPPConstructor b2 = getBindingFromASTName("B(0)", 1, ICPPConstructor.class);
+ assertFalse(b2 instanceof IIndexBinding);
+ assertEquals(b1, b2);
+ ICPPMethod b3 = getBindingFromASTName("m(0)", 1, ICPPMethod.class);
+ assertFalse(b3 instanceof IIndexBinding);
+ }
+
+ // class A {
// friend inline void m(A p) {}
// };
@@ -1462,7 +1490,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
}
/**
- * @param binding
+ * @param type
* @param cqn
* @param qn may be null
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
index 33d8156f28..f654b82cdd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
@@ -348,7 +348,11 @@ public class CPPSemantics {
if (data.considerConstructors) {
if (binding instanceof ICPPClassType) {
+ if (binding instanceof IIndexBinding) {
+ binding= data.tu.mapToAST((ICPPClassType) binding);
+ }
ICPPClassType cls= (ICPPClassType) binding;
+
try {
if (data.astName instanceof ICPPASTTemplateId && cls instanceof ICPPClassTemplate) {
if (data.tu != null) {
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 b1729a40d3..61f615a60b 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
@@ -219,11 +219,15 @@ public class CPPVisitor extends ASTQueries {
return binding;
}
} else {
- return binding;
+ if (binding instanceof ICPPClassType && binding instanceof IIndexBinding && name.isDefinition()) {
+ parent= parent.getParent(); // need to create an ast binding.
+ } else {
+ return binding;
+ }
}
} else if (parent instanceof ICPPASTTemplateId) {
final ICPPASTTemplateId id = (ICPPASTTemplateId) parent;
- if (CPPTemplates.isClassTemplate(id))
+ if (CPPTemplates.isClassTemplate(id))
return CPPSemantics.resolveBinding(name);
// function templates/instances/specializations must be resolved via the id

Back to the top