2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / inherit / operator1.C
blob6ef669c219e6ac71cee1082d5ac65fcff0ccfd50
1 // Test that conversions to base classes happen when calling
2 // operators.
4 // { dg-do run }
6 extern "C" void abort ();
8 struct B1;
9 struct B2;
11 B2* p;
12 B1* p2;
14 struct B1 {
15   virtual void f () {}
18 struct B2 {
19   int i;
20   bool operator!() { if (this != p) abort (); return true; }
21   operator void*() { if (this != p) abort (); return this; }
24 struct B3 : public B1, public B2 {
27 int main () {
28   B3 b;
29   p = (B2*) &b;
30   p2 = (B1*) &b;
31   bool b1 = b;
32   bool b2 = !b;