Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.other/pmf6.C

raw
1 // { dg-do run }
2 // Test that we only call f once and that pointers to different subobjects
3 // compare as different.
4
5 struct A { void f() { } };
6 struct B: public A { };
7 struct C: public A { };
8 struct D : public B, public C { };
9
10 typedef void (B::*bp)();
11 typedef void (C::*cp)();
12 typedef void (D::*dp)();
13
14 dp d1;
15
16 int call;
17
18 dp f () { ++call; return d1; }
19
20 int main()
21 {
22 bp b = &A::f;
23 cp c = &A::f;
24 d1 = b;
25 dp d2 = c;
26 return (f() == d2 || call != 1);
27 }