1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 245068.

This commit is contained in:
Sergey Prigogin 2008-10-12 23:48:35 +00:00
parent cb5c6721aa
commit 44b6373985
2 changed files with 22 additions and 2 deletions

View file

@ -6119,6 +6119,22 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(ors[0], m1); assertSame(ors[0], m1);
} }
// struct A {
// int a;
// };
//
// void test(A* p) {
// p.a; // should not resolve
// }
public void testPointerMemberAccess_245068() throws Exception {
final String comment= getAboveComment();
final boolean[] isCpps= {false, true};
for (boolean isCpp : isCpps) {
BindingAssertionHelper ba= new BindingAssertionHelper(comment, isCpp);
ba.assertProblem("a; // should not resolve", 1);
}
}
// void f(); // void f();
// //
// void test(int p) { // void test(int p) {

View file

@ -925,7 +925,11 @@ public class CPPVisitor {
} else if (parent instanceof ICPPASTFieldReference) { } else if (parent instanceof ICPPASTFieldReference) {
final ICPPASTFieldReference fieldReference = (ICPPASTFieldReference)parent; final ICPPASTFieldReference fieldReference = (ICPPASTFieldReference)parent;
IType type = CPPSemantics.getChainedMemberAccessOperatorReturnType(fieldReference); IType type = CPPSemantics.getChainedMemberAccessOperatorReturnType(fieldReference);
if (fieldReference.isPointerDereference()) {
type= getUltimateType(type, false); type= getUltimateType(type, false);
} else {
type= getUltimateTypeUptoPointers(type);
}
if (type instanceof ICPPClassType) { if (type instanceof ICPPClassType) {
return ((ICPPClassType) type).getCompositeScope(); return ((ICPPClassType) type).getCompositeScope();
} }