1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 449099 - IllegalArgumentException: waldo is not a member of A

This commit is contained in:
Sergey Prigogin 2014-10-28 14:43:40 -07:00
parent c28c3c5aab
commit 653d74eceb
3 changed files with 36 additions and 28 deletions

View file

@ -414,7 +414,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2); testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2);
if (testData.length < 2) if (testData.length < 2)
return; fail("Insufficient test data");
IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString()); IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString());
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
waitForIndexer(cproject); waitForIndexer(cproject);
@ -500,6 +500,8 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
Bundle b = CTestPlugin.getDefault().getBundle(); Bundle b = CTestPlugin.getDefault().getBundle();
testData = TestSourceReader.getContentsForTest(b, "parser", IndexBindingResolutionTestBase.this.getClass(), getName(), 2); 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()); IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString());
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
waitForIndexer(cproject); waitForIndexer(cproject);

View file

@ -1854,12 +1854,21 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
// //
// struct test { // struct test {
// // These lambdas have the class 'test' as their owner. // // These lambdas have the class 'test' as their owner.
// test(function f = [](int c){ return c; }); // test(function f = [](int c) { return c; });
// function member = [](int c){ return c; }; // function member = [](int c) { return c; };
// }; // };
// int z; // 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(); checkBindings();
} }

View file

@ -2614,36 +2614,33 @@ public class CPPVisitor extends ASTQueries {
boolean isFriend= isFriendDeclaration(node); boolean isFriend= isFriendDeclaration(node);
// Search for enclosing binding // Search for enclosing binding.
IASTName name= null; for (node= node.getParent(); node != null; node= node.getParent()) {
node= node.getParent();
for (; node != null; node= node.getParent()) {
if (node instanceof IASTFunctionDefinition) { if (node instanceof IASTFunctionDefinition) {
if (!allowFunction) if (allowFunction) {
return null;
IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator());
if (dtor != null) { if (dtor != null) {
name= dtor.getName(); return dtor.getName();
} }
break; }
return null;
} }
if (node instanceof IASTCompositeTypeSpecifier) { if (node instanceof IASTCompositeTypeSpecifier) {
if (isFriend || isNonSimpleElabDecl) if (isFriend || isNonSimpleElabDecl)
continue; continue;
name= ((IASTCompositeTypeSpecifier) node).getName(); return ((IASTCompositeTypeSpecifier) node).getName();
break;
} }
if (node instanceof ICPPASTNamespaceDefinition) { if (node instanceof ICPPASTNamespaceDefinition) {
name= ((ICPPASTNamespaceDefinition) node).getName(); return ((ICPPASTNamespaceDefinition) node).getName();
break;
} }
if (node instanceof ICPPASTEnumerationSpecifier) { if (node instanceof ICPPASTEnumerationSpecifier) {
name= ((ICPPASTEnumerationSpecifier) node).getName(); return ((ICPPASTEnumerationSpecifier) node).getName();
break; }
if (node instanceof ICPPASTLambdaExpression) {
return ((ICPPASTLambdaExpression) node).getClosureTypeName();
} }
} }
return name; return null;
} }
public static boolean doesNotSpecifyType(IASTDeclSpecifier declspec) { public static boolean doesNotSpecifyType(IASTDeclSpecifier declspec) {