1 // { dg-do assemble } 2 // 980604 bkoz 3 // 3.4.5 Class member access p 4 4 // nested and non-nested calls, no dtors 5 6 struct L { 7 int ii; fooL8 void foo(int a) {++a;} 9 struct Linner { 10 int ii_inner; foo_innerL::Linner11 void foo_inner(int b) {++b;} 12 }; 13 }; 14 class A : public L {}; 15 class B : public L {}; 16 class C : public A, public B {}; 17 18 foo()19void foo() { 20 // straight call 21 C x; 22 x.A::ii = 5; 23 x.A::foo(x.A::ii); 24 25 // 5.1 Primary expressions 26 // p 8 27 // a nested name specifier that names a class, 28 // optionally followed by the keyword template and then followd by 29 // the name of a member of either that class or one of its base 30 // classes is a qualified-id. (3.4.3.1 describes their lookup.) 31 32 // 5.2.5 Class memember access 33 34 // p 3 if E1 has the type 'pointer to class X' then 35 // E1->E2 == (*(E1)).E32 36 // E1 == object-expression 37 // E2 == id-expression 38 // thus everything gets converted to the "." notation 39 40 // p 2 41 // the id-expression shall name a member of the class 42 // (object-expression) or of one of its base classes. 43 44 // p4 if E2 is a nested type (of the object-expression), tye 45 // expression E1.E2 is ill formed. 46 47 // try 1 nested call - ERROR 48 #if 0 49 C x2; 50 x2.A::L::Linner::ii_inner = 6; //ERROR violates p2, does not name member of C 51 x2.A::L::Linner::foo_inner(x2.A::L::Linner::ii_inner); 52 #endif 53 54 //try2: scoped method call -edg +acc +g++ 55 #if 1 56 C::A::Linner x2; 57 x2.A::Linner::ii_inner = 6; 58 x2.A::Linner::foo_inner(x2.A::Linner::ii_inner); 59 #endif 60 61 //try 3: non-scoped method call -edg +acc +g++ 62 #if 0 63 C::A::L::Linner x3; 64 x3.ii_inner = 6; 65 x3.foo_inner(x3.ii_inner); 66 #endif 67 } 68 69 70 71 72