[llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp/C++Catch.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Sep 23 11:07:08 PDT 2003
Changes in directory llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp:
C++Catch.cpp added (r1.1)
---
Log message:
New sjlj testcase
---
Diffs of the changes:
Index: llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp/C++Catch.cpp
diff -c /dev/null llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp/C++Catch.cpp:1.1
*** /dev/null Tue Sep 23 11:06:12 2003
--- llvm/test/Programs/SingleSource/UnitTests/SetjmpLongjmp/C++Catch.cpp Tue Sep 23 11:06:02 2003
***************
*** 0 ****
--- 1,30 ----
+ #include <cstdio>
+ #include <csetjmp>
+
+ class C {
+ const char *name;
+ public:
+ C(const char *n) : name(n) {}
+ ~C() { printf("Destroying C in function %s\n", name); }
+ };
+
+ jmp_buf buf;
+
+ void foo()
+ {
+ C Obj("foo");
+ printf("Longjmping from foo() function\n");
+ longjmp(buf, 37);
+ }
+
+ int main()
+ {
+ try {
+ C Obj("main");
+ if (!setjmp(buf)) foo();
+ printf("longjmp throw NOT caught in catch(...) block\n");
+ } catch(...) {
+ printf("Caught longjmp throw in catch(...) block\n");
+ }
+ }
+
More information about the llvm-commits
mailing list