From e6ed5e40374c66f6eee1428a36524f28d610c904 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Mon, 13 Jun 2016 15:24:53 -0400 Subject: [PATCH] Bug 494182 - Lambda in default member initializer Change-Id: I92bbfaff34a08952d3f17f6a9b982a10d4e2bf03 --- .../cdt/core/parser/tests/ast2/AST2CPPTests.java | 12 ++++++++++++ .../core/dom/parser/cpp/semantics/CPPVisitor.java | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 7328cf80177..982201ce1be 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -9572,6 +9572,18 @@ public class AST2CPPTests extends AST2TestBase { public void testLambdaExpression_316307b() throws Exception { parseAndCheckBindings(); } + + // struct function { + // template + // function(T); + // }; + // struct S { + // void waldo(); + // function f = [this](){ waldo(); }; + // }; + public void testLambdaInDefaultMemberInitializer_494182() throws Exception { + parseAndCheckBindings(); + } // typedef int MyType; // 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 55fe872626c..f9b9d459bc9 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 @@ -2378,6 +2378,14 @@ public class CPPVisitor extends ASTQueries { break; if (node.getParent() instanceof IASTFunctionDefinition) break; + } else if (scope instanceof ICPPClassScope) { + // Reached a class scope without a function scope in between. + // Might be in the default member initializer on a field. + IType type = ((ICPPClassScope) scope).getClassType(); + if (type instanceof ICPPClassTemplate) { + type= (ICPPClassType) ((ICPPClassTemplate) type).asDeferredInstance(); + } + return type; } scope = scope.getParent(); }