| author | Nathan Ridge | 2012-12-07 15:29:07 (EST) |
|---|---|---|
| committer | Sergey Prigogin | 2012-12-07 17:08:49 (EST) |
| commit | c21f219ab7e8eff57e34845db1020861526fc083 (patch) (side-by-side diff) | |
| tree | bbc232a4feb289a581c3b5e76dee5e448e21882a | |
| parent | 88b19449f211113eb5a54159b3e70e4faf4ea630 (diff) | |
| download | org.eclipse.cdt-c21f219ab7e8eff57e34845db1020861526fc083.zip org.eclipse.cdt-c21f219ab7e8eff57e34845db1020861526fc083.tar.gz org.eclipse.cdt-c21f219ab7e8eff57e34845db1020861526fc083.tar.bz2 | |
Bug 395875 - Error involving dependent expression in indexrefs/changes/64/9064/3
Change-Id: I2f50373220a02d5856fb88cf040c44de28fb5a79
Reviewed-on: https://git.eclipse.org/r/9064
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
2 files changed, 25 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index 0e8fded..57ffaef 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -9,6 +9,7 @@ * Andrew Ferguson (Symbian) - Initial implementation * Markus Schorn (Wind River Systems) * Sergey Prigogin (Google) + * Nathan Ridge *******************************************************************************/ package org.eclipse.cdt.internal.index.tests; @@ -2175,4 +2176,18 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa public void testLambdaExpression_395884() throws Exception { checkBindings(); } + + // template <typename T> int bar(T); + // template <int N> struct S { + // template <typename T> auto foo(T t) const -> decltype(bar(t)); + // }; + + // void f(int); + // void test() { + // S<1> n; + // f(n.foo(0)); + // } + public void testDependentExpression_395875() throws Exception { + getBindingFromASTName("f(n.foo(0))", 1, ICPPFunction.class); + } } 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 bb1138e..7b634dc 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,13 +2434,19 @@ public class CPPVisitor extends ASTQueries { * Searches for the function enclosing the given node. May return <code>null</code>. */ public static IBinding findEnclosingFunction(IASTNode node) { - while (node != null && !(node instanceof IASTFunctionDefinition)) { + IASTDeclarator dtor = null; + while (node != null) { + if (node instanceof IASTFunctionDeclarator) { + dtor = (IASTDeclarator) node; + break; + } + if (node instanceof IASTFunctionDefinition) { + dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); + break; + } node= node.getParent(); } - if (node == null) - return null; - IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); if (dtor != null) { IASTName name= dtor.getName(); if (name != null) { |

