From 129297342f0eba484b6e3d7f82dd08f233cfa50f Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 17 Oct 2008 13:10:37 +0000 Subject: [PATCH] NPE resolving template-id in using-decl, bug 251199. --- .../cdt/core/parser/tests/ast2/AST2CPPTests.java | 8 ++++++++ .../core/dom/parser/cpp/semantics/CPPTemplates.java | 12 ++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) 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 &&