From 52f41040802643e3374bffa6ac874aaf474299f3 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 26 Oct 2016 16:46:36 -0700 Subject: [PATCH] Fixed an NPE. Change-Id: I20e5a2c2a452159224cd8af5a3e0c434801b67cc --- .../internal/core/dom/parser/cpp/CPPFunctionScope.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java index 9c10e74482a..81378b95d0e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java @@ -86,9 +86,12 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope { public IScope getParent() { // We can't just resolve the function and get its parent scope, since there are cases where that // could loop because resolving functions requires resolving their parameter types. - IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator) getPhysicalNode(); - IASTName name = fdtor.getName().getLastName(); - return CPPVisitor.getContainingNonTemplateScope(name); + IASTFunctionDeclarator funcDeclarator = (IASTFunctionDeclarator) getPhysicalNode(); + IASTName name = funcDeclarator.getName(); + if (name != null) + return CPPVisitor.getContainingNonTemplateScope(name.getLastName()); + + return super.getParent(); } @Override