diff options
| author | Chris Lattner <sabre@nondot.org> | 2003-08-27 04:57:33 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2003-08-27 04:57:33 +0000 |
| commit | 7b972a24e173c68002f9e51e2cc6bec6d498bb4d (patch) | |
| tree | 7caa8452c56ad0f1206ce3af4eaa9f6356fe835b /llvm/test/Regression/C++Frontend | |
| parent | 5e22eb1942e5cf229109309bee309146db8f88ff (diff) | |
| download | bcm5719-llvm-7b972a24e173c68002f9e51e2cc6bec6d498bb4d.tar.gz bcm5719-llvm-7b972a24e173c68002f9e51e2cc6bec6d498bb4d.zip | |
New testcases, which WORK with LLVMG++ and the CBE.
llvm-svn: 8158
Diffstat (limited to 'llvm/test/Regression/C++Frontend')
| -rw-r--r-- | llvm/test/Regression/C++Frontend/EH/simple_throw.cpp | 13 | ||||
| -rw-r--r-- | llvm/test/Regression/C++Frontend/EH/throw_rethrow_test.cpp | 40 |
2 files changed, 53 insertions, 0 deletions
diff --git a/llvm/test/Regression/C++Frontend/EH/simple_throw.cpp b/llvm/test/Regression/C++Frontend/EH/simple_throw.cpp new file mode 100644 index 00000000000..7289c6d065c --- /dev/null +++ b/llvm/test/Regression/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/llvm/test/Regression/C++Frontend/EH/throw_rethrow_test.cpp b/llvm/test/Regression/C++Frontend/EH/throw_rethrow_test.cpp new file mode 100644 index 00000000000..cbaaa1bf568 --- /dev/null +++ b/llvm/test/Regression/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); + } + } +} + |

