1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 395875 - Error involving dependent expression in index

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>
This commit is contained in:
Nathan Ridge 2012-12-07 12:29:07 -08:00 committed by Sergey Prigogin
parent 88b19449f2
commit c21f219ab7
2 changed files with 25 additions and 4 deletions

View file

@ -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);
}
}

View file

@ -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) {