diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 4f7179838f4..9f1b8e148b7 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -6134,6 +6134,14 @@ public class AST2CPPTests extends AST2BaseTest { ba.assertProblem("a; // should not resolve", 1); } } + + // namespace ns { + // template class CT {}; + // } + // using ns::CT; + public void testTemplateIDInUsingDecl_251199() throws Exception { + parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); + } // void f(); // diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 06c6a574995..c5cdc6c4c73 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -470,10 +470,14 @@ public class CPPTemplates { parent = parent.getParent(); } - IASTNode decl = parent.getParent(); - while (!(decl instanceof IASTDeclaration)) - decl = decl.getParent(); - decl = decl.getParent(); + IASTNode decl= parent; + while (decl != null) { + if (decl instanceof IASTDeclaration) { + decl= decl.getParent(); + break; + } + decl= decl.getParent(); + } try { if (decl instanceof ICPPASTExplicitTemplateInstantiation &&