mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Create problem bindings for non-existent fields, bug 228504.
This commit is contained in:
parent
d844f5e24a
commit
e54c6c45a7
2 changed files with 33 additions and 2 deletions
|
@ -4636,7 +4636,6 @@ public class AST2Tests extends AST2BaseTest {
|
|||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
}
|
||||
|
||||
|
||||
// int f(x) {
|
||||
// return 0;
|
||||
// }
|
||||
|
@ -4644,4 +4643,34 @@ public class AST2Tests extends AST2BaseTest {
|
|||
StringBuffer buffer = getContents(1)[0];
|
||||
parse(buffer.toString(), ParserLanguage.C, false );
|
||||
}
|
||||
|
||||
// struct {
|
||||
// char foo;
|
||||
// } myStruct, *myStructPointer;
|
||||
//
|
||||
// union {
|
||||
// char foo;
|
||||
// } myUnion, *myUnionPointer;
|
||||
//
|
||||
// void test() {
|
||||
// myStruct.foo=1;
|
||||
// myStructPointer->foo=2;
|
||||
// myUnion.foo=3;
|
||||
// myUnionPointer->foo=4;
|
||||
//
|
||||
// myStruct.bar=1;
|
||||
// myStructPointer->bar=2;
|
||||
// myUnion.bar=3;
|
||||
// myUnionPointer->bar=4;
|
||||
// }
|
||||
public void testBug228504_nonExistingMembers() throws Exception {
|
||||
boolean[] isCpps= {true, false};
|
||||
for (boolean isCpp : isCpps) {
|
||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), isCpp);
|
||||
for (int i=1; i < 5; i++) {
|
||||
ba.assertNonProblem("foo=" + i, 3);
|
||||
ba.assertProblem("bar=" + i, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -490,6 +489,9 @@ public class CVisitor {
|
|||
binding = resolveBinding( parent );
|
||||
} else if( parent instanceof IASTFieldReference ){
|
||||
binding = (IBinding) findBinding( (IASTFieldReference) parent, false );
|
||||
if (binding == null) {
|
||||
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, name.toCharArray());
|
||||
}
|
||||
} else if( parent instanceof IASTDeclarator ){
|
||||
binding = createBinding( (IASTDeclarator) parent, name );
|
||||
} else if( parent instanceof ICASTCompositeTypeSpecifier ){
|
||||
|
|
Loading…
Add table
Reference in a new issue