aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-27 04:57:33 +0000
committerChris Lattner <sabre@nondot.org>2003-08-27 04:57:33 +0000
commit065c0b95a3960f228f8898f520100b053e243fb6 (patch)
treedad769a4a9ee16f0b700de8ef49bd0d3b9b365ee
parent5eb79390570ffd5674f260621988afac2b91a60d (diff)
downloadexternal_llvm-065c0b95a3960f228f8898f520100b053e243fb6.zip
external_llvm-065c0b95a3960f228f8898f520100b053e243fb6.tar.gz
external_llvm-065c0b95a3960f228f8898f520100b053e243fb6.tar.bz2
New testcases, which WORK with LLVMG++ and the CBE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8158 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/C++Frontend/EH/simple_throw.cpp13
-rw-r--r--test/C++Frontend/EH/throw_rethrow_test.cpp40
2 files changed, 53 insertions, 0 deletions
diff --git a/test/C++Frontend/EH/simple_throw.cpp b/test/C++Frontend/EH/simple_throw.cpp
new file mode 100644
index 0000000..7289c6d
--- /dev/null
+++ b/test/C++Frontend/EH/simple_throw.cpp
@@ -0,0 +1,13 @@
+// Test throwing a constant int
+#include <stdio.h>
+
+static void foo() { throw 5; }
+int main() {
+ try {
+ foo();
+ } catch (...) {
+ printf("All ok\n");
+ return 0;
+ }
+ return 1;
+}
diff --git a/test/C++Frontend/EH/throw_rethrow_test.cpp b/test/C++Frontend/EH/throw_rethrow_test.cpp
new file mode 100644
index 0000000..cbaaa1b
--- /dev/null
+++ b/test/C++Frontend/EH/throw_rethrow_test.cpp
@@ -0,0 +1,40 @@
+// This tests hard situations for throwing, including the case where an
+// exception is active in more than one handler at a time (ie, it needs
+// refcounting)
+#include <cstdio>
+
+struct foo {
+ int i;
+ foo() : i(1) { }
+ foo(const foo&) : i(2) {}
+};
+
+int callee(unsigned i) {
+ if (i < 3) throw (int)i;
+ if (i < 6) throw 1.0;
+ if (i < 9) throw foo();
+ return 0;
+}
+
+void rethrow() {
+ throw;
+}
+
+int main() {
+ for (unsigned i = 0; i < 10; ++i) {
+ try {
+ return callee(i);
+ } catch (foo &F) {
+ try {
+ rethrow();
+ } catch (foo &F) {
+ std::printf("%d: 3\n", i);
+ }
+ } catch (int) {
+ std::printf("%d: 1\n", i);
+ } catch (...) {
+ std::printf("%d: 2\n", i);
+ }
+ }
+}
+