Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / g++.dg / eh / init-temp1.C
blob29eae6972d63629e17dd79fb76e220088df3a911
1 // PR c++/15764
3 extern "C" void abort (); 
4  
5 int counter = 0; 
6 int thrown; 
7 struct a { 
8   ~a () { if (thrown++ == 0) throw 42; } 
9 }; 
11 int f (a const&) { return 1; } 
12 int f (a const&, a const&) { return 1; } 
14 struct b { 
15   b (...) { ++counter; } 
16   ~b ()   { --counter; } 
17 }; 
19 bool p;
20 void g()
22   if (p) throw 42;
25 int main () { 
26   thrown = 0;
27   try {
28     b tmp(f (a(), a()));
30     g();
31   }  
32   catch (...) {} 
34   thrown = 0;
35   try {
36     b tmp(f (a()));
38     g();
39   }  
40   catch (...) {} 
42   if (counter != 0) 
43     abort (); 
44