2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.brendan / eh1.C
blob939312a00d8295e7744c203d036095a8c7b94b8e
1 // { dg-do run  }
2 // { dg-options "-O" }
3 // PRMS Id: 10776
5 extern "C" int printf (const char *, ...);
7 class Foo 
9   public:
10     Foo(int n) : n_(n) { }
11     int f() { return n_; }
12     
13     int badTest();
14     int goodTest();
15     
16   private:
18     int n_;
21 int Foo::badTest()
23     try {
24         throw int(99);
25     }
27     catch (int &i) {
28         n_ = 16;
29     }
31     return n_;
32         // On the sparc, the return will use a ld [%l0],%i0 instruction.
33         // However %l0 was clobbered at the end of the catch block.  It was
34         // used to do an indirect call.
38 int Foo::goodTest()
40     int n;
42     try {
43         throw int(99);
44     }
46     catch (int &i) {
47         n = 16;
48     }
50     return n_;
51         // The return will use a ld [%l2],%i0 instruction.  Since %l2
52         // contains the "this" pointer this works.
55 int main() 
57     Foo foo(5);
58     foo.goodTest();
59     foo.badTest();
61     // the badTest will have failed
62     printf ("PASS\n");