]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
This commit was manufactured by cvs2svn to create branch
authorNo Author <no-author@gcc.gnu.org>
Fri, 21 Nov 1997 21:36:00 +0000 (21:36 +0000)
committerNo Author <no-author@gcc.gnu.org>
Fri, 21 Nov 1997 21:36:00 +0000 (21:36 +0000)
'egcs_1_00_branch'.

From-SVN: r16658

gcc/testsuite/g++.old-deja/g++.eh/pdel1.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.eh/pdel2.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.eh/rethrow1.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.eh/rethrow2.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.eh/rethrow3.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.eh/spec1.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.eh/spec2.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.eh/spec4.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.old-deja/g++.eh/pdel1.C b/gcc/testsuite/g++.old-deja/g++.eh/pdel1.C
new file mode 100644 (file)
index 0000000..b30b402
--- /dev/null
@@ -0,0 +1,22 @@
+// Test for calling placement delete.
+
+#include <new>
+#include <stddef.h>
+
+int r = 1;
+
+struct A {
+  A() { throw 1; }
+  void operator delete (void *p, int, int) { r = 0; ::operator delete (p); }
+};
+
+void * operator new (size_t size, int, int) { return operator new (size); }
+
+main ()
+{
+  try {
+    A* ap = new (1, 5) A;
+  } catch (...) {  }
+
+  return r;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/pdel2.C b/gcc/testsuite/g++.old-deja/g++.eh/pdel2.C
new file mode 100644 (file)
index 0000000..c9b9bd1
--- /dev/null
@@ -0,0 +1,22 @@
+// Test for not calling mismatched placement delete.
+
+#include <new>
+#include <stddef.h>
+
+int r = 0;
+
+struct A {
+  A() { throw 1; }
+  void operator delete (void *p, int, long) { r = 1; ::operator delete (p); }
+};
+
+void * operator new (size_t size, int, int) { return operator new (size); }
+
+main ()
+{
+  try {
+    A* ap = new (1, 5) A;
+  } catch (...) {  }
+
+  return r;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow1.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow1.C
new file mode 100644 (file)
index 0000000..ef4dcb4
--- /dev/null
@@ -0,0 +1,45 @@
+// Testcase for proper handling of rethrow.
+
+#include <stdio.h>
+
+int c, d;
+
+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; }
+};
+
+int
+main ()
+{
+  try
+    {
+      try
+       {
+         printf ("Throwing 1...\n");
+         throw A();
+       }
+      catch (A)
+       {
+         try
+           {
+             printf ("Throwing 2...\n");
+             throw A();
+           }
+         catch (A)
+           {
+             printf ("Throwing 3...\n");
+             throw;
+           }
+       }
+    }
+  catch (A)
+    {
+      printf ("Caught.\n");
+    }
+  printf ("c == %d, d == %d\n", c, d);
+  return c != d;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow2.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow2.C
new file mode 100644 (file)
index 0000000..2d2583b
--- /dev/null
@@ -0,0 +1,45 @@
+// Testcase for proper handling of rethrow.
+
+#include <stdio.h>
+
+int c, d;
+
+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; }
+};
+
+int
+main ()
+{
+  try
+    {
+      try
+       {
+         printf ("Throwing 1...\n");
+         throw A();
+       }
+      catch (A)
+       {
+         try
+           {
+             printf ("Throwing 2...\n");
+             throw;
+           }
+         catch (A)
+           {
+             printf ("Throwing 3...\n");
+             throw;
+           }
+       }
+    }
+  catch (A)
+    {
+      printf ("Caught.\n");
+    }
+  printf ("c == %d, d == %d\n", c, d);
+  return c != d;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow3.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow3.C
new file mode 100644 (file)
index 0000000..355bedc
--- /dev/null
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <exception>
+
+static void
+eh_terminate ()
+{
+  printf ("CALLING TERMINATE\n");
+  exit (1);
+}
+
+void
+eh_test (int level)
+{
+  try
+    {
+      if (level < 2)
+       eh_test (level + 1);
+      else
+       {
+         printf ("%d: Throwing\n", level);
+         throw (level);
+       }
+    }
+  catch (int &x)
+    {
+      printf ("%d: Got level %d\n",
+             level, x);
+
+      if (level > 0)
+       throw;
+    }
+}
+
+main ()
+{
+  set_terminate (&eh_terminate);
+  eh_test (0);
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec1.C b/gcc/testsuite/g++.old-deja/g++.eh/spec1.C
new file mode 100644 (file)
index 0000000..73ee960
--- /dev/null
@@ -0,0 +1,38 @@
+// Testing exception specifications.
+// Test 1: the original exception succeeds.
+
+#include <stdlib.h>
+#include <exception>
+
+void my_term ()  { exit (1); }
+void my_unexp () { throw 42; }
+
+void
+f () throw (char, int, bad_exception)
+{
+  throw 'a';
+}
+
+main ()
+{
+  set_terminate (my_term);
+  set_unexpected (my_unexp);
+
+  try
+    {
+      f ();
+    }
+  catch (char)
+    {
+      return 0;
+    }
+  catch (int)
+    {
+      return 3;
+    }
+  catch (bad_exception)
+    {
+      return 4;
+    }
+  return 5;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec2.C b/gcc/testsuite/g++.old-deja/g++.eh/spec2.C
new file mode 100644 (file)
index 0000000..4401377
--- /dev/null
@@ -0,0 +1,38 @@
+// Testing exception specifications.
+// Test 2: the second throw succeeds.
+
+#include <stdlib.h>
+#include <exception>
+
+void my_term ()  { exit (1); }
+void my_unexp () { throw 42; }
+
+void
+f () throw (int, bad_exception)
+{
+  throw 'a';
+}
+
+main ()
+{
+  set_terminate (my_term);
+  set_unexpected (my_unexp);
+
+  try
+    {
+      f ();
+    }
+  catch (char)
+    {
+      return 2;
+    }
+  catch (int)
+    {
+      return 0;
+    }
+  catch (bad_exception)
+    {
+      return 4;
+    }
+  return 5;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec4.C b/gcc/testsuite/g++.old-deja/g++.eh/spec4.C
new file mode 100644 (file)
index 0000000..d8b8ce7
--- /dev/null
@@ -0,0 +1,38 @@
+// Testing exception specifications.
+// Test 4: all throws fail, call terminate.
+
+#include <stdlib.h>
+#include <exception>
+
+void my_term ()  { exit (0); }
+void my_unexp () { throw 42; }
+
+void
+f () throw (short)
+{
+  throw 'a';
+}
+
+main ()
+{
+  set_terminate (my_term);
+  set_unexpected (my_unexp);
+
+  try
+    {
+      f ();
+    }
+  catch (char)
+    {
+      return 2;
+    }
+  catch (int)
+    {
+      return 3;
+    }
+  catch (bad_exception)
+    {
+      return 4;
+    }
+  return 5;
+}