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