From 9745cb982655172e4a354dd967e80dee06ad3bc5 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Mon, 26 Aug 2013 02:01:28 -0400 Subject: Bug 413204 - "field could not be resolved" error in function returning function pointer (really fixed this time) Change-Id: Ica4255ca554db6952248fe1fae53d188a1b78d75 Signed-off-by: Nathan Ridge Reviewed-on: https://git.eclipse.org/r/15840 Reviewed-by: Sergey Prigogin IP-Clean: Sergey Prigogin Tested-by: Sergey Prigogin --- .../parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java | 2 +- .../org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 816f687659d..f4358768c91 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -7459,7 +7459,7 @@ public class AST2Tests extends AST2TestBase { // a->x; // } public void testFunctionReturningFunctionPointer_413204() throws Exception { - parseAndCheckBindings(getAboveComment(), CPP); + parseAndCheckBindings(); } // double d = 00.9; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java index f0a49f4fce3..16b1839d170 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java @@ -727,12 +727,9 @@ public class CVisitor extends ASTQueries { boolean isFunction= false; if (parent instanceof IASTParameterDeclaration || parent.getPropertyInParent() == ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER) { IASTDeclarator fdtor = (IASTDeclarator) parent.getParent(); - if (ASTQueries.findTypeRelevantDeclarator(fdtor) instanceof IASTFunctionDeclarator) { - IASTDeclarator dtor = fdtor; - while (dtor.getNestedDeclarator() != null && !(dtor.getNestedDeclarator() instanceof IASTFunctionDeclarator)) { - dtor = dtor.getNestedDeclarator(); - } - IASTName n = dtor.getName(); + // Create parameter bindings only if the declarator declares a function + if (ASTQueries.findTypeRelevantDeclarator(fdtor) == fdtor) { + IASTName n = ASTQueries.findInnermostDeclarator(fdtor).getName(); IBinding temp = n.resolveBinding(); if (temp != null && temp instanceof CFunction) { binding = ((CFunction) temp).resolveParameter(name); -- cgit v1.2.3