1// { dg-do run  }
2// check cleanup of template temporaries
3extern "C" void abort ();
4extern "C" void exit (int);
5
6int ctor = 0;
7int dtor = 0;
8
9template <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
17template <class T> void ff(T);
18
19template <class T> void ff(T)
20{
21}
22
23void g(int)
24{
25}
26
27void 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
56int
57main()
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