2018-10-23 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / eh / ehopt1.C
blob9e713ac9781292ba4d6b9dacc22d93fbb47e448b
1 // ehopt was only copying one statement from the cleanup of the B temporary
2 // into the following try block, so we lost its destructor call.
4 // { dg-do run }
6 template <class T, class U>
7 class A;
9 bool b;
10 int count;
12 template <>
13 class A<int, int>
15 public:
16   A(int) { ++count; if (b) throw 1; }
17   A(const A&) { ++count; if (b) throw 1; }
18   ~A()
19 #if __cplusplus <= 201402L
20   throw(int)                    // { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } }
21 #else
22   noexcept(false)
23 #endif
24   { --count; if (b) throw 1; }
27 typedef A<int, int> B;
29 template <>
30 class A<void *, void *>
32 public:
33   A() { if (b) throw 1; }
34   A(const B&) { if (b) throw 1; }
35   ~A()
36 #if __cplusplus <= 201402L
37   throw(int)                    // { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } }
38 #else
39   noexcept(false)
40 #endif
41   { if (b) throw 1; }
44 typedef A<void *, void *> C;
46 void f() { if (b) throw 1; }
48 int
49 main (void)
51   {
52     C a(1);
53     f();
54   }
55   return count;