summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.eh
diff options
context:
space:
mode:
authorYamaArashi <shadow962@live.com>2016-01-06 01:47:28 -0800
committerYamaArashi <shadow962@live.com>2016-01-06 01:47:28 -0800
commitbe8b04496302184c6e8f04d6179f9c3afc50aeb6 (patch)
tree726e2468c0c07add773c0dbd86ab6386844259ae /gcc/testsuite/g++.old-deja/g++.eh
initial commit
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.eh')
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/cleanup1.C34
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/ctor1.C15
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/flow1.C21
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/new1.C44
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/new2.C44
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/pdel1.C22
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/pdel2.C22
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/ptr1.C22
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/rethrow1.C45
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/rethrow2.C45
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/rethrow3.C38
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/rethrow4.C45
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/rethrow5.C44
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/spec1.C38
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/spec2.C38
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/spec3.C38
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/spec4.C38
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/spec5.C3
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/throw1.C12
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/throw2.C16
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/tmpl1.C15
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/tmpl2.C33
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/tmpl3.C11
-rwxr-xr-xgcc/testsuite/g++.old-deja/g++.eh/unwind1.C24
24 files changed, 707 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C b/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C
new file mode 100755
index 0000000..6faea26
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/cleanup1.C
@@ -0,0 +1,34 @@
+// Bug: obj gets destroyed twice because the fixups for the return are
+// inside its cleanup region.
+
+extern "C" int printf (const char *, ...);
+
+int d;
+
+struct myExc { };
+
+struct myExcRaiser {
+ ~myExcRaiser() { throw myExc(); }
+};
+
+struct stackObj {
+ ~stackObj() { ++d; printf ("stackObj::~stackObj()\n"); };
+};
+
+int test()
+{
+ myExcRaiser rais;
+ stackObj obj;
+ return 0;
+}
+
+int main()
+{
+ try {
+ test();
+ }
+ catch (myExc &) {
+ return d != 1;
+ }
+ return 1;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/ctor1.C b/gcc/testsuite/g++.old-deja/g++.eh/ctor1.C
new file mode 100755
index 0000000..9874131
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/ctor1.C
@@ -0,0 +1,15 @@
+struct A
+{
+ A();
+ A(A&); // ERROR - referenced below
+};
+
+int
+main ()
+{
+ try
+ {
+ throw A(); // ERROR - can't copy
+ }
+ catch (...) { }
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/flow1.C b/gcc/testsuite/g++.old-deja/g++.eh/flow1.C
new file mode 100755
index 0000000..024670c
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/flow1.C
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+int bar ()
+{
+ throw 100;
+}
+
+int main ()
+{
+ int i = 0; // this gets deleted after flow analysis
+ try
+ {
+ i = bar ();
+ }
+ catch (...)
+ {
+ }
+
+ printf ("i = %d\n", i);
+ return i;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/new1.C b/gcc/testsuite/g++.old-deja/g++.eh/new1.C
new file mode 100755
index 0000000..1671dbb
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/new1.C
@@ -0,0 +1,44 @@
+// Test that a throw in foo destroys the A, but does not free the memory.
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <new.h>
+
+struct A {
+ A();
+ ~A();
+};
+
+struct B {
+ B (A);
+};
+
+void foo (B*);
+
+int newed, created;
+
+int main ()
+{
+ try {
+ foo (new B (A ()));
+ } catch (...) { }
+
+ return !(newed && !created);
+}
+
+A::A() { created = 1; }
+A::~A() { created = 0; }
+B::B(A) { }
+void foo (B*) { throw 1; }
+
+void* operator new (size_t size) throw (std::bad_alloc)
+{
+ ++newed;
+ return (void *) malloc (size);
+}
+
+void operator delete (void *p) throw ()
+{
+ --newed;
+ free (p);
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/new2.C b/gcc/testsuite/g++.old-deja/g++.eh/new2.C
new file mode 100755
index 0000000..17bea5e
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/new2.C
@@ -0,0 +1,44 @@
+// Test that a throw in B's constructor destroys the A and frees the memory.
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <new.h>
+
+struct A {
+ A();
+ ~A();
+};
+
+struct B {
+ B (A);
+};
+
+void foo (B*);
+
+int newed, created;
+
+int main ()
+{
+ try {
+ foo (new B (A ()));
+ } catch (...) { }
+
+ return !(!newed && !created);
+}
+
+A::A() { created = 1; }
+A::~A() { created = 0; }
+B::B(A) { throw 1; }
+void foo (B*) { }
+
+void* operator new (size_t size) throw (std::bad_alloc)
+{
+ ++newed;
+ return (void *) malloc (size);
+}
+
+void operator delete (void *p) throw ()
+{
+ --newed;
+ free (p);
+}
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 100755
index 0000000..b8e553c
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/pdel1.C
@@ -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); }
+
+int 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 100755
index 0000000..12efcd3
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/pdel2.C
@@ -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); }
+
+int main ()
+{
+ try {
+ A* ap = new (1, 5) A;
+ } catch (...) { }
+
+ return r;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C b/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C
new file mode 100755
index 0000000..9101e9e
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C
@@ -0,0 +1,22 @@
+// Bug: catching pointers by reference doesn't work right.
+
+extern "C" int printf (const char *, ...);
+
+struct E {
+ int x;
+ E(int i) { x = i; };
+};
+
+int main()
+{
+ try {
+ E *p = new E(5);
+ throw p;
+ }
+
+ catch (E *&e) {
+ printf ("address of e is 0x%lx\n", (long)e);
+ return !(long(e) != 5 && e->x == 5);
+ }
+ return 2;
+}
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 100755
index 0000000..ef4dcb4
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow1.C
@@ -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 100755
index 0000000..2d2583b
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow2.C
@@ -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 100755
index 0000000..5da2081
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow3.C
@@ -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;
+ }
+}
+
+int main ()
+{
+ std::set_terminate (&eh_terminate);
+ eh_test (0);
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/rethrow4.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow4.C
new file mode 100755
index 0000000..c5dcd23
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow4.C
@@ -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 A();
+ }
+ }
+ }
+ 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/rethrow5.C b/gcc/testsuite/g++.old-deja/g++.eh/rethrow5.C
new file mode 100755
index 0000000..f137d18
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/rethrow5.C
@@ -0,0 +1,44 @@
+// 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 ("Falling out...\n");
+ }
+ }
+ }
+ 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/spec1.C b/gcc/testsuite/g++.old-deja/g++.eh/spec1.C
new file mode 100755
index 0000000..044af8c
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/spec1.C
@@ -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, std::bad_exception)
+{
+ throw 'a';
+}
+
+int main ()
+{
+ std::set_terminate (my_term);
+ std::set_unexpected (my_unexp);
+
+ try
+ {
+ f ();
+ }
+ catch (char)
+ {
+ return 0;
+ }
+ catch (int)
+ {
+ return 3;
+ }
+ catch (std::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 100755
index 0000000..d0269b3
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/spec2.C
@@ -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, std::bad_exception)
+{
+ throw 'a';
+}
+
+int main ()
+{
+ std::set_terminate (my_term);
+ std::set_unexpected (my_unexp);
+
+ try
+ {
+ f ();
+ }
+ catch (char)
+ {
+ return 2;
+ }
+ catch (int)
+ {
+ return 0;
+ }
+ catch (std::bad_exception)
+ {
+ return 4;
+ }
+ return 5;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec3.C b/gcc/testsuite/g++.old-deja/g++.eh/spec3.C
new file mode 100755
index 0000000..57b29d4
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/spec3.C
@@ -0,0 +1,38 @@
+// Testing exception specifications.
+// Test 3: the bad_exception throw succeeds.
+
+#include <stdlib.h>
+#include <exception>
+
+void my_term () { exit (1); }
+void my_unexp () { throw 42; }
+
+void
+f () throw (std::bad_exception)
+{
+ throw 'a';
+}
+
+int main ()
+{
+ std::set_terminate (my_term);
+ std::set_unexpected (my_unexp);
+
+ try
+ {
+ f ();
+ }
+ catch (char)
+ {
+ return 2;
+ }
+ catch (int)
+ {
+ return 3;
+ }
+ catch (std::bad_exception)
+ {
+ return 0;
+ }
+ 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 100755
index 0000000..a92f7f0
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/spec4.C
@@ -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';
+}
+
+int main ()
+{
+ std::set_terminate (my_term);
+ std::set_unexpected (my_unexp);
+
+ try
+ {
+ f ();
+ }
+ catch (char)
+ {
+ return 2;
+ }
+ catch (int)
+ {
+ return 3;
+ }
+ catch (std::bad_exception)
+ {
+ return 4;
+ }
+ return 5;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec5.C b/gcc/testsuite/g++.old-deja/g++.eh/spec5.C
new file mode 100755
index 0000000..56154f9
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/spec5.C
@@ -0,0 +1,3 @@
+// Build don't link:
+
+extern void *f(unsigned int k) throw();
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/throw1.C b/gcc/testsuite/g++.old-deja/g++.eh/throw1.C
new file mode 100755
index 0000000..49a7d1e
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/throw1.C
@@ -0,0 +1,12 @@
+// Build don't link:
+
+void athrow(const int & e) throw(int)
+{
+ throw e;
+}
+
+int main(void)
+{
+ athrow(int());
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/throw2.C b/gcc/testsuite/g++.old-deja/g++.eh/throw2.C
new file mode 100755
index 0000000..fbf0cec
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/throw2.C
@@ -0,0 +1,16 @@
+// Build don't link:
+
+// Submitted by Sebastian Ritterbusch <uabp@rz.uni-karlsruhe.de>
+
+#define ANY int // a class with a public constructor
+
+void athrow(const ANY & e) throw(ANY)
+{
+ throw e; // gets bogus error - discarding const
+}
+
+int main(void)
+{
+ athrow(ANY());
+ return 0;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/tmpl1.C b/gcc/testsuite/g++.old-deja/g++.eh/tmpl1.C
new file mode 100755
index 0000000..cdbd6e1
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/tmpl1.C
@@ -0,0 +1,15 @@
+template <class T>
+void f() throw (T)
+{
+ throw 7;
+}
+
+
+int main()
+{
+ try {
+ f<int>();
+ } catch (...) {
+ return 0;
+ }
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/tmpl2.C b/gcc/testsuite/g++.old-deja/g++.eh/tmpl2.C
new file mode 100755
index 0000000..af3dc7b
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/tmpl2.C
@@ -0,0 +1,33 @@
+// Build don't link:
+// Special g++ flags: -O
+// crash test - XFAIL i*86-*-linux*
+
+// Posted by H. J. Lu <hjl@lucon.org>
+
+template<class T>
+class FixSeq
+{
+public:
+ void append(const T&);
+};
+class foo
+{
+public:
+ void setupIR();
+};
+typedef FixSeq<foo *> bar;
+extern void dummy (foo *);
+void *
+foobar (bar &x, foo *p)
+{
+ try
+ {
+ p -> setupIR();
+ }
+ catch(...)
+ {
+ dummy (p);
+ }
+ x.append(p);
+ return p;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/tmpl3.C b/gcc/testsuite/g++.old-deja/g++.eh/tmpl3.C
new file mode 100755
index 0000000..521315e
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/tmpl3.C
@@ -0,0 +1,11 @@
+// Build don't link:
+
+// Posted by Trevor Taylor <ttaylor@powerup.com.au>
+
+template<class T> struct A {
+ void X() throw(T);
+};
+
+template<class T>
+inline void A<T>::X()
+throw(T) { }
diff --git a/gcc/testsuite/g++.old-deja/g++.eh/unwind1.C b/gcc/testsuite/g++.old-deja/g++.eh/unwind1.C
new file mode 100755
index 0000000..617b355
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.eh/unwind1.C
@@ -0,0 +1,24 @@
+// Test that unwinding properly restores SP.
+// Contributed by Jason Merrill <jason@cygnus.com>
+
+int f (int i)
+{
+ throw i;
+}
+
+int main ()
+{
+ void *sp1 = __builtin_alloca (0);
+
+ try
+ {
+ f (0);
+ }
+ catch (int)
+ {
+ }
+
+ void *sp2 = __builtin_alloca (0);
+
+ return (sp1 != sp2);
+}