diff options
author | Brendan Kehoe <brendan@gcc.gnu.org> | 1998-03-25 08:47:06 -0500 |
---|---|---|
committer | Brendan Kehoe <brendan@gcc.gnu.org> | 1998-03-25 08:47:06 -0500 |
commit | dba21b324a641191fbca5a481ec23b1d765cb718 (patch) | |
tree | 1ec7387bd9963f4edd525e54bed03237b01c1ff1 | |
parent | 8e73900b4eb4cf4ab91d89aa79a9d8842ffe5146 (diff) | |
download | gcc-dba21b324a641191fbca5a481ec23b1d765cb718.zip gcc-dba21b324a641191fbca5a481ec23b1d765cb718.tar.gz gcc-dba21b324a641191fbca5a481ec23b1d765cb718.tar.bz2 |
new test for EH w/ opt on
From-SVN: r18829
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.brendan/eh1.C | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/eh1.C b/gcc/testsuite/g++.old-deja/g++.brendan/eh1.C new file mode 100644 index 0000000..a668306 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.brendan/eh1.C @@ -0,0 +1,62 @@ +// Special g++ Options: -O +// PRMS Id: 10776 + +extern "C" void printf (char *, ...); + +class Foo +{ + public: + Foo(int n) : n_(n) { } + int f() { return n_; } + + int badTest(); + int goodTest(); + + private: + + int n_; +}; + +int Foo::badTest() +{ + try { + throw int(99); + } + + catch (int &i) { + n_ = 16; + } + + return n_; + // On the sparc, the return will use a ld [%l0],%i0 instruction. + // However %l0 was clobbered at the end of the catch block. It was + // used to do an indirect call. +} + + +int Foo::goodTest() +{ + int n; + + try { + throw int(99); + } + + catch (int &i) { + n = 16; + } + + return n_; + // The return will use a ld [%l2],%i0 instruction. Since %l2 + // contains the "this" pointer this works. +} + +int main() +{ + Foo foo(5); + foo.goodTest(); + foo.badTest(); + + // the badTest will have failed + printf ("PASS\n"); +} |