Home | History | Annotate | Download | only in jni
      1 // { dg-do run  }
      2 // check cleanup of template temporaries
      3 extern "C" void abort ();
      4 extern "C" void exit (int);
      5 
      6 int ctor = 0;
      7 int dtor = 0;
      8 
      9 template <class T> struct A {
     10 	A() {ctor++;}
     11 	A(int) {ctor++;}
     12 	A(const A&) {ctor++;}
     13 	~A() {dtor++;}
     14 	operator int() {return 0;}
     15 };
     16 
     17 template <class T> void ff(T);
     18 
     19 template <class T> void ff(T)
     20 {
     21 }
     22 
     23 void g(int)
     24 {
     25 }
     26 
     27 void f()
     28 {
     29 	int x;
     30 
     31 	A<int> a1;
     32 	A<double> a2(37);
     33 	A<long> a3 = A<long>(47);
     34 	A<short> a4 = 97;
     35 
     36 	g(A<char*>());
     37 
     38 	A<char**>();
     39 
     40 	x ? A<char*>() : A<char*>();
     41 
     42 	x = 47, A<double*>(), A<int>(39), A<void>(23), -17;
     43 
     44 	while (A<short>())
     45 		;
     46 	for (;A<unsigned>(3);)
     47 		;
     48 	if (A<A<double> >())
     49 		;
     50 
     51 	ff(A<double>());
     52 
     53 	throw 59;
     54 }
     55 
     56 int
     57 main()
     58 {
     59 	int flag = 0;
     60 
     61 	try {
     62 		A<unsigned long>();
     63 		f();
     64 	}
     65 	catch (int) {
     66 		A<float>(34);
     67 		flag = 1;
     68 	}
     69 
     70 	if (!flag)
     71 		abort();
     72 
     73 	if (!ctor || ctor != dtor)
     74 		abort();
     75 
     76 	exit(0);
     77 }
     78