FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.robertl / eh990323-1.C
blob40df1551d00797d3872aa05d83791a56dbfe8762
1 // check cleanup of template temporaries
2 extern "C" void abort ();
3 extern "C" void exit (int);
5 int ctor = 0;
6 int dtor = 0;
8 template <class T> struct A {
9         A() {ctor++;}
10         A(int) {ctor++;}
11         A(const A&) {ctor++;}
12         ~A() {dtor++;}
13         operator int() {return 0;}
16 template <class T> void ff(T);
18 template <class T> void ff(T)
22 void g(int)
26 void f()
28         int x;
30         A<int> a1;
31         A<double> a2(37);
32         A<long> a3 = A<long>(47);
33         A<short> a4 = 97;
35         g(A<char*>());
37         A<char**>();
39         x ? A<char*>() : A<char*>();
41         x = 47, A<double*>(), A<int>(39), A<void>(23), -17;
43         while (A<short>())
44                 ;
45         for (;A<unsigned>(3);)
46                 ;
47         if (A<A<double> >())
48                 ;
50         ff(A<double>());
52         throw 59;
55 int 
56 main()
58         int flag = 0;
60         try {
61                 A<unsigned long>();
62                 f();
63         }
64         catch (int) {
65                 A<float>(34);
66                 flag = 1;
67         }
69         if (!flag)
70                 abort();
72         if (!ctor || ctor != dtor)
73                 abort();
75         exit(0);