[llvm-commits] [test-suite] r140336 - in /test-suite/trunk/SingleSource/UnitTests/EH: filter-2.cpp filter-2.reference_output
Bill Wendling
isanbard at gmail.com
Thu Sep 22 13:33:15 PDT 2011
Author: void
Date: Thu Sep 22 15:33:15 2011
New Revision: 140336
URL: http://llvm.org/viewvc/llvm-project?rev=140336&view=rev
Log:
EH testcase. This tests r140335.
Added:
test-suite/trunk/SingleSource/UnitTests/EH/filter-2.cpp
test-suite/trunk/SingleSource/UnitTests/EH/filter-2.reference_output
Added: test-suite/trunk/SingleSource/UnitTests/EH/filter-2.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/EH/filter-2.cpp?rev=140336&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/EH/filter-2.cpp (added)
+++ test-suite/trunk/SingleSource/UnitTests/EH/filter-2.cpp Thu Sep 22 15:33:15 2011
@@ -0,0 +1,50 @@
+#include <exception>
+#include <iostream>
+
+void unexpected_float() {
+ std::cout << "Throwing in unexpected(): 927.37\n";
+ throw 927.37f;
+}
+
+void unexpected_int() {
+ std::set_unexpected(unexpected_float);
+ std::cout << "Throwing in unexpected(): 42\n";
+ throw 42;
+}
+
+void qux() __attribute__((always_inline));
+void qux() {
+ std::cout << "Throwing in qux(): \"hello world\"\n";
+ throw "hello world";
+}
+
+void bar() throw (int) __attribute__((always_inline));
+void bar() throw (int) {
+ std::set_unexpected(unexpected_int);
+ try {
+ qux();
+ } catch (int i) {
+ std::cout << "Caught in bar(): " << i << "\n";
+ exit(EXIT_FAILURE);
+ }
+}
+
+void foo() throw (float) {
+ try {
+ bar();
+ } catch (const char *s) {
+ std::cout << "Caught in foo(): " << s << "\n";
+ exit(EXIT_FAILURE);
+ }
+}
+
+int main() {
+ try {
+ foo();
+ } catch (float f) {
+ std::cout << "Caught in main(): " << f << "\n";
+ } catch (...) {
+ std::cout << "Caught in main(): catch all\n";
+ exit(EXIT_FAILURE);
+ }
+}
Added: test-suite/trunk/SingleSource/UnitTests/EH/filter-2.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/EH/filter-2.reference_output?rev=140336&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/EH/filter-2.reference_output (added)
+++ test-suite/trunk/SingleSource/UnitTests/EH/filter-2.reference_output Thu Sep 22 15:33:15 2011
@@ -0,0 +1,5 @@
+Throwing in qux(): "hello world"
+Throwing in unexpected(): 42
+Throwing in unexpected(): 927.37
+Caught in main(): 927.37
+exit 0
More information about the llvm-commits
mailing list