summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2012-12-07 15:29:07 (EST)
committer Sergey Prigogin2012-12-07 17:12:39 (EST)
commit33d13f264353588e3e59e55f3c0aa5c41f9f9ae0 (patch)
tree64f2dfee99137684e47256bacc021b901cd03eb4
parent12637bcda31ffa3e165a7008ae33f842c388de6f (diff)
downloadorg.eclipse.cdt-33d13f264353588e3e59e55f3c0aa5c41f9f9ae0.zip
org.eclipse.cdt-33d13f264353588e3e59e55f3c0aa5c41f9f9ae0.tar.gz
org.eclipse.cdt-33d13f264353588e3e59e55f3c0aa5c41f9f9ae0.tar.bz2
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>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java14
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 044de05..4970707 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
@@ -2435,13 +2435,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) {