[llvm-commits] CVS: llvm/test/Regression/C++Frontend/EH/simple_throw.cpp throw_rethrow_test.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Aug 26 23:58:01 PDT 2003
Changes in directory llvm/test/Regression/C++Frontend/EH:
simple_throw.cpp added (r1.1)
throw_rethrow_test.cpp added (r1.1)
---
Log message:
New testcases, which WORK with LLVMG++ and the CBE.
---
Diffs of the changes:
Index: llvm/test/Regression/C++Frontend/EH/simple_throw.cpp
diff -c /dev/null llvm/test/Regression/C++Frontend/EH/simple_throw.cpp:1.1
*** /dev/null Tue Aug 26 23:57:43 2003
--- llvm/test/Regression/C++Frontend/EH/simple_throw.cpp Tue Aug 26 23:57:33 2003
***************
*** 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;
+ }
Index: llvm/test/Regression/C++Frontend/EH/throw_rethrow_test.cpp
diff -c /dev/null llvm/test/Regression/C++Frontend/EH/throw_rethrow_test.cpp:1.1
*** /dev/null Tue Aug 26 23:57:43 2003
--- llvm/test/Regression/C++Frontend/EH/throw_rethrow_test.cpp Tue Aug 26 23:57:33 2003
***************
*** 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);
+ }
+ }
+ }
+
More information about the llvm-commits
mailing list