Debian Codegraph @

gcc/testsuite/g++.dg/inherit/operator1.C

raw
1 // Test that conversions to base classes happen when calling
2 // operators.
3
4 // { dg-do run }
5
6 extern "C" void abort ();
7
8 struct B1;
9 struct B2;
10
11 B2* p;
12 B1* p2;
13
14 struct B1 {
15 virtual void f () {}
16 };
17
18 struct B2 {
19 int i;
20 bool operator!() { if (this != p) abort (); return true; }
21 operator void*() { if (this != p) abort (); return this; }
22 };
23
24 struct B3 : public B1, public B2 {
25 };
26
27 int main () {
28 B3 b;
29 p = (B2*) &b;
30 p2 = (B1*) &b;
31 bool b1 = b;
32 bool b2 = !b;
33 }
34