summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2000-06-03 02:07:51 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2000-06-03 02:07:51 +0000
commiteb0a9cd2a91690797accfce718072698a65813cc (patch)
tree79ca53adb8ea4b09171d455d688caf367deb2d57
parent851dfbff5aa2084e3f50cba54afc38909269eae9 (diff)
downloadppe42-gcc-eb0a9cd2a91690797accfce718072698a65813cc.tar.gz
ppe42-gcc-eb0a9cd2a91690797accfce718072698a65813cc.zip
new
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34374 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.eh/rethrow6.C75
1 files changed, 75 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow6.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow6.C
new file mode 100644
index 00000000000..56f61efe0cd
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow6.C
@@ -0,0 +1,75 @@
+// Testcase for proper handling of rethrow.
+
+#include <stdio.h>
+
+int c, d;
+int wrong;
+
+struct A
+{
+ int i;
+ A () { i = c++; printf ("A() %d\n", i); }
+ A (const A&) { i = c++; printf ("A(const A&) %d\n", i); }
+ ~A() { printf ("~A() %d\n", i); ++d; }
+};
+
+struct B
+{
+ ~B () {
+ try
+ {
+ printf ("Rethrowing III...\n");
+ throw;
+ }
+ catch (A& a)
+ {
+ printf ("Caught III %d...\n", a.i);
+ if (a.i != 1)
+ {
+ printf ("** rethrew uncaught exception **\n");
+ wrong = 1;
+ }
+ }
+ printf ("continuing to unwind II...\n");
+ }
+};
+
+int
+main ()
+{
+ {
+ A a;
+
+ try
+ {
+ try
+ {
+ printf ("Throwing I...\n");
+ throw a;
+ }
+ catch (A& a)
+ {
+ printf ("Caught I %d...\n", a.i);
+ try
+ {
+ B b;
+ printf ("Throwing II...\n");
+ throw a;
+ }
+ catch (A& a)
+ {
+ printf ("Caught II %d...\n", a.i);
+ printf ("Throwing IV...\n");
+ throw;
+ }
+ }
+ }
+ catch (A& a)
+ {
+ printf ("Caught IV %d.\n", a.i);
+ }
+ }
+
+ printf ("c == %d, d == %d\n", c, d);
+ return c != d || wrong;
+}
OpenPOWER on IntegriCloud