From 33a7f1e53349bdef9c5bc45926bd8c6410630248 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Tue, 15 Aug 2017 19:54:34 -0400 Subject: [PATCH] Bug 520999 - Map PDOM class types to AST before looking up constructors Change-Id: Iac865cbde8ed4ba2b002eea0da7d943598d33bc1 --- .../tests/IndexCPPBindingResolutionTest.java | 15 +++++++++++++++ .../dom/parser/cpp/semantics/CPPSemantics.java | 6 ++++++ 2 files changed, 21 insertions(+) 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 16401af5f38..b5c61238202 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 @@ -2480,4 +2480,19 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas public void testSelfReferencingVariable_510484() throws Exception { checkBindings(); } + + // class Foo { + // struct Bar; + // void func(); + // }; + + // struct Foo::Bar { + // Bar(int, int); + // }; + // void Foo::func() { + // Bar waldo(0, 0); + // } + public void testNestedClassDefinedOutOfLine_502999() throws Exception { + checkBindings(); + } } 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 9b624e67ecc..241eacb07fc 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 @@ -3593,6 +3593,12 @@ public class CPPSemantics { return null; if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownType || type instanceof ISemanticProblem) return null; + + // The class type may be declared in a header but defined in the AST. + // In such a case, we want the constructors as AST bindings (since as + // index bindings they would fail declaredBefore() filtering), so map + // the class type to its AST representation. + type = SemanticUtil.mapToAST(type, name); return findImplicitlyCalledConstructor((ICPPClassType) type, initializer, name); }