[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / eh / uncaught1.C
blob4f05be59fd1a253ac4d20e666206d06deab82622
1 // PR libstdc++/10606
2 // { dg-do run }
3 // { dg-options "-Wno-deprecated" }
4 // { dg-options "-fuse-cxa-get-exception-ptr -Wno-deprecated" { target powerpc*-*-darwin* } }
6 #include <exception>
7 #include <cstdlib>
10 struct Check {
11   int obj1, obj2;
12   bool state;
15 static Check const data[] = {
16   { 0, 0, false },      // construct [0]
17   { 1, 0, false  },     // [1] = [0]
18   { 0, 0, true  },      // destruct [0]
19   { 2, 1, true  },      // [2] = [1]
20   { 2, 2, true  },      // destruct [2]
21   { 3, 1, true  },      // [3] = [1]
22   { 3, 3, false },      // destruct [3]
23   { 1, 1, false },      // destruct [1]
24   { 9, 9, false }       // end-of-data
27 static int pos = 0;
29 static void test(int obj1, int obj2, bool state)
31   if (obj1 != data[pos].obj1) abort ();
32   if (obj2 != data[pos].obj2) abort ();
33   if (state != data[pos].state) abort ();
34   pos++;
38 struct S {
39   int id;
40   S ();
41   S (const S &);
42   ~S ();
45 static int next_id = 0;
47 S::S()
48   : id (next_id++)
50   test (id, id, std::uncaught_exception ());
53 S::S(const S &x)
54   : id (next_id++)
56   test (id, x.id, std::uncaught_exception ());
59 S::~S()
61   test (id, id, std::uncaught_exception ());
64 extern void foo (S *);
66 int main()
68   try
69     {
70       try
71         {
72           S s0;
73           throw s0;     // s1 is the exception object
74         }
75       catch (S s2)
76         {
77           throw;
78         }
79     }
80   catch (S s3)
81     {
82     }
84   return 0;