diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java index bb3c28109da..ee3c6684a2a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java @@ -414,7 +414,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2); if (testData.length < 2) - return; + fail("Insufficient test data"); IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString()); CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); waitForIndexer(cproject); @@ -500,6 +500,8 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { Bundle b = CTestPlugin.getDefault().getBundle(); testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2); + if (testData.length < 2) + fail("Insufficient test data"); IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString()); CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); waitForIndexer(cproject); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java index a105629e638..0137fa4a614 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java @@ -1836,17 +1836,17 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti public void testInheritedConstructorFromUnknownClass() throws Exception { checkBindings(); } - + // constexpr int foo(int a = 42) { // return a; // } - + // constexpr int waldo = foo(); public void testNameLookupInDefaultArgument_432701() throws Exception { IVariable waldo = getBindingFromASTName("waldo", 5); assertEquals(42, waldo.getInitialValue().numericalValue().longValue()); } - + // struct function { // template // function(T); @@ -1854,17 +1854,26 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti // // struct test { // // These lambdas have the class 'test' as their owner. - // test(function f = [](int c){ return c; }); - // function member = [](int c){ return c; }; + // test(function f = [](int c) { return c; }); + // function member = [](int c) { return c; }; // }; - + // int z; - public void testLambdaOwnedByClass() throws Exception { + public void testLambdaOwnedByClass_409882() throws Exception { checkBindings(); } - + + // struct A { + // auto a = [](int p) { int waldo = p; return waldo; }; + // }; + + // // No code in this file. + public void testLambdaOwnedByClass_449099() throws Exception { + checkBindings(); + } + // extern char TableValue[10]; - + // char TableValue[sizeof TableValue]; public void testNameLookupFromArrayModifier_435075() throws Exception { checkBindings(); 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 d989bebf7f3..cb9fc12a8eb 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 @@ -2614,36 +2614,33 @@ public class CPPVisitor extends ASTQueries { boolean isFriend= isFriendDeclaration(node); - // Search for enclosing binding - IASTName name= null; - node= node.getParent(); - for (; node != null; node= node.getParent()) { + // Search for enclosing binding. + for (node= node.getParent(); node != null; node= node.getParent()) { if (node instanceof IASTFunctionDefinition) { - if (!allowFunction) - return null; - - IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); - if (dtor != null) { - name= dtor.getName(); + if (allowFunction) { + IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); + if (dtor != null) { + return dtor.getName(); + } } - break; + return null; } if (node instanceof IASTCompositeTypeSpecifier) { if (isFriend || isNonSimpleElabDecl) continue; - name= ((IASTCompositeTypeSpecifier) node).getName(); - break; + return ((IASTCompositeTypeSpecifier) node).getName(); } if (node instanceof ICPPASTNamespaceDefinition) { - name= ((ICPPASTNamespaceDefinition) node).getName(); - break; + return ((ICPPASTNamespaceDefinition) node).getName(); } if (node instanceof ICPPASTEnumerationSpecifier) { - name= ((ICPPASTEnumerationSpecifier) node).getName(); - break; + return ((ICPPASTEnumerationSpecifier) node).getName(); + } + if (node instanceof ICPPASTLambdaExpression) { + return ((ICPPASTLambdaExpression) node).getClosureTypeName(); } } - return name; + return null; } public static boolean doesNotSpecifyType(IASTDeclSpecifier declspec) {