ice990323-2.cpp revision 31ad4de047c50cddfc3072be3a82232c53f1ca2d
1// { dg-do run } 2// check EH with templates 3extern "C" void abort (); 4extern "C" void exit (int); 5 6template <class T, int n, class U> struct A { 7 A() {} 8 A(const char*) {} 9}; 10 11void f1() 12{ 13 throw *(new A<double, 47, A<int, 37, short> >); 14} 15 16void f2() 17{ 18 throw *(new A<double, 47, A<int, 36, short> >); 19} 20 21void f3() 22{ 23 throw A<double, 47, A<int, 37, short> > ("howdy"); 24} 25 26void f4() 27{ 28 throw A<double, 47, A<int, 36, short> > ("hi michey"); 29} 30 31int main() 32{ 33 int flag; 34 35 flag = 0; 36 try { 37 f1(); 38 } 39 catch (A<double, 47, A<int, 36, short> >) { 40 abort(); 41 } 42 catch (A<double, 47, A<int, 37, short> >) { 43 flag = 1; 44 } 45 if (!flag) 46 abort(); 47 48 flag = 0; 49 try { 50 f2(); 51 } 52 catch (A<double, 47, A<int, 36, short&> >) { 53 abort(); 54 } 55 catch (A<double, 47, A<int, 36, short> >) { 56 flag = 1; 57 } 58 if (!flag) 59 abort(); 60 61 flag = 0; 62 try { 63 f3(); 64 } 65 catch (A<double, 47, A<int, 36, short> >) { 66 abort(); 67 } 68 catch (A<double, 47, A<int, 37, short> >) { 69 flag = 1; 70 } 71 if (!flag) 72 abort(); 73 74 flag = 0; 75 try { 76 f4(); 77 } 78 catch (A<double, 47, A<int, 36, short&> >) { 79 abort(); 80 } 81 catch (A<double, 47, A<int, 36, short> >) { 82 flag = 1; 83 } 84 if (!flag) 85 abort(); 86 87 exit(0); 88} 89