1 // { dg-do run } 2 // check MI and VBC offsets on throw 3 extern "C" void abort (); 4 extern "C" void exit (int); 5 6 struct A { 7 int x[23]; 8 }; 9 10 struct B : virtual public A { 11 int y[33]; 12 }; 13 14 struct C : virtual public A, public B { 15 int z[43]; 16 }; 17 18 struct D { 19 int xx[53]; 20 }; 21 22 struct E : public D, public A { 23 int yy[63]; 24 }; 25 26 C c; 27 28 E e; 29 30 void f1() 31 { 32 throw (C*)0; 33 } 34 35 void f2() 36 { 37 throw &c; 38 } 39 40 void f3() 41 { 42 throw (E*)0; 43 } 44 45 void f4() 46 { 47 throw &e; 48 } 49 50 int 51 main() 52 { 53 int flag; 54 55 flag = 0; 56 try { 57 f1(); 58 } 59 catch (void* p) { 60 if (p) 61 abort(); 62 flag = 1; 63 } 64 if (!flag) 65 abort(); 66 67 flag = 0; 68 try { 69 f2(); 70 } 71 catch (void* p) { 72 if (!p || (void*)p != (void*)&c) 73 abort(); 74 flag = 1; 75 } 76 if (!flag) 77 abort(); 78 79 flag = 0; 80 try { 81 f3(); 82 } 83 catch (void* p) { 84 if (p) 85 abort(); 86 flag = 1; 87 } 88 if (!flag) 89 abort(); 90 91 flag = 0; 92 try { 93 f4(); 94 } 95 catch (void* p) { 96 if (!p || (void*)p != (void*)&e) 97 abort(); 98 flag = 1; 99 } 100 if (!flag) 101 abort(); 102 103 exit(0); 104 } 105