1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 00:36:16 +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

@ -1836,17 +1836,17 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
public void testInheritedConstructorFromUnknownClass() throws Exception { public void testInheritedConstructorFromUnknownClass() throws Exception {
checkBindings(); checkBindings();
} }
// constexpr int foo(int a = 42) { // constexpr int foo(int a = 42) {
// return a; // return a;
// } // }
// constexpr int waldo = foo(); // constexpr int waldo = foo();
public void testNameLookupInDefaultArgument_432701() throws Exception { public void testNameLookupInDefaultArgument_432701() throws Exception {
IVariable waldo = getBindingFromASTName("waldo", 5); IVariable waldo = getBindingFromASTName("waldo", 5);
assertEquals(42, waldo.getInitialValue().numericalValue().longValue()); assertEquals(42, waldo.getInitialValue().numericalValue().longValue());
} }
// struct function { // struct function {
// template <typename T> // template <typename T>
// function(T); // function(T);
@ -1854,17 +1854,26 @@ 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(); 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]; // extern char TableValue[10];
// char TableValue[sizeof TableValue]; // char TableValue[sizeof TableValue];
public void testNameLookupFromArrayModifier_435075() throws Exception { public void testNameLookupFromArrayModifier_435075() 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());
if (dtor != null) {
IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()); return dtor.getName();
if (dtor != null) { }
name= 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) {