1 // PR target/12301
2 // Origin: Colin Hirsch <gcc@cohi.at>
3 // Testcase by Christian Ehrhardt <ehrhardt@mathematik.uni-ulm.de>
4 
5 // This used to fail on SPARC because the reorg pass moved an insn
6 // across a function call that can throw internally, in order to put
7 // it in a delay slot.
8 
9 // { dg-do run }
10 // { dg-options "-O" }
11 
12 struct S{
13   char *c;
14   char data[100];
SS15   S () : c (data) {};
SS16   S (const S& s) {
17     c = data;
18     data[0] = s.c[0];
19   }
20 };
21 
real_cast()22 S real_cast ()
23 {
24   throw 3;
25 }
26 
cast_helper(S & debug)27 S cast_helper(S& debug)
28 {
29   try {
30     return real_cast();
31   }
32   catch (int e) {
33     throw debug;
34   }
35 }
36 
main()37 int main()
38 {
39   S tmp;
40 
41   try {
42     cast_helper (tmp);
43   }
44   catch (S& e) {}
45 
46   return 0;
47 }
48