1 // { dg-do compile }
2 // { dg-final { scan-assembler-not "__cxa_get_exception" } }
3 // { dg-options "-fno-use-cxa-get-exception-ptr -Wno-deprecated" }
4 
5 #include <exception>
6 #include <cstdlib>
7 
8 
9 struct Check {
10   int obj1, obj2;
11   bool state;
12 };
13 
14 static Check const data[] = {
15   { 0, 0, false },	// construct [0]
16   { 1, 0, true  },	// [1] = [0]
17   { 0, 0, true  },	// destruct [0]
18   { 2, 1, true  },	// [2] = [1]
19   { 2, 2, true  },      // destruct [2]
20   { 3, 1, true  },	// [3] = [1]
21   { 3, 3, false },	// destruct [3]
22   { 1, 1, false },	// destruct [1]
23   { 9, 9, false }	// end-of-data
24 };
25 
26 static int pos = 0;
27 
test(int obj1,int obj2,bool state)28 static void test(int obj1, int obj2, bool state)
29 {
30   if (obj1 != data[pos].obj1) abort ();
31   if (obj2 != data[pos].obj2) abort ();
32   if (state != data[pos].state) abort ();
33   pos++;
34 }
35 
36 
37 struct S {
38   int id;
39   S ();
40   S (const S &);
41   ~S ();
42 };
43 
44 static int next_id = 0;
45 
S()46 S::S()
47   : id (next_id++)
48 {
49   test (id, id, std::uncaught_exception ());
50 }
51 
S(const S & x)52 S::S(const S &x)
53   : id (next_id++)
54 {
55   test (id, x.id, std::uncaught_exception ());
56 }
57 
~S()58 S::~S()
59 {
60   test (id, id, std::uncaught_exception ());
61 }
62 
63 extern void foo (S *);
64 
main()65 int main()
66 {
67   try
68     {
69       try
70 	{
71 	  S s0;
72 	  throw s0;	// s1 is the exception object
73 	}
74       catch (S s2)
75 	{
76 	  throw;
77 	}
78     }
79   catch (S s3)
80     {
81     }
82 
83   return 0;
84 }
85