1 // { dg-do assemble }
2 // g++ 1.36.1 bug 900215_02
3
4 // g++ allows global objects (which happen to be pointers to members of some
5 // class X) to be dereferenced without prefix object specifications within
6 // member functions of class X.
7
8 // In effect, g++ treats any dereference of a pointer-to-member which appears
9 // within the context of a member function (and which is not preceeded by
10 // either ->* or .*) as if it had been implicitly prefixed with this->*.
11
12 // The 2.0 Reference Manual only provides that such implicit prefixing
13 // takes place for *members* of the containing class, and *not* for
14 // global objects that happen to have certain types (i.e. pointer-to-member
15 // of the containing class).
16
17 // Also, cfront 2.0 provides implicit this-> prefixes *only* for *members*
18 // of the containing class.
19
20 // Cfront 2.0 passes this test.
21
22 // keywords: member pointers, this, dereference, members
23
24 struct struct0 {
25 int data_member;
26 void function_member ();
27 };
28
29 int struct0::*dmp;
30 int (struct0::*fmp) ();
31 int i;
32
33 struct struct1 {
34 int data_member;
35
36 void function_member ();
37 };
38
function_member()39 void struct0::function_member ()
40 {
41 i = (this->*fmp) (); // perfectly legal - for both cfront and g++
42 i = this->*dmp; // perfectly legal - for both cfront and g++
43
44 i = (*fmp) (); // { dg-error "invalid use of unary '\\\*' on pointer to member" }
45 i = *dmp; // { dg-error "invalid use of unary '\\\*' on pointer to member" }
46 }
47
main()48 int main () { return 0; }
49