diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java index e49137afdc1..b576015775a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java @@ -257,7 +257,12 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI @Override public IBinding getOwner() { - return CPPVisitor.findEnclosingFunction(fDeclarations[0]); + IASTFunctionDeclarator decl = + CPPVisitor.findAncestorWithType(fDeclarations[0], IASTFunctionDeclarator.class); + if (decl == null) + return null; + IASTName name= decl.getName(); + return name != null ? name.resolveBinding() : null; } @Override 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 7b634dc0f5d..bb1138eb81a 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 @@ -2434,19 +2434,13 @@ public class CPPVisitor extends ASTQueries { * Searches for the function enclosing the given node. May return null. */ public static IBinding findEnclosingFunction(IASTNode node) { - IASTDeclarator dtor = null; - while (node != null) { - if (node instanceof IASTFunctionDeclarator) { - dtor = (IASTDeclarator) node; - break; - } - if (node instanceof IASTFunctionDefinition) { - dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); - break; - } + while (node != null && !(node instanceof IASTFunctionDefinition)) { node= node.getParent(); } + if (node == null) + return null; + IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); if (dtor != null) { IASTName name= dtor.getName(); if (name != null) {