summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/nothrow1.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/opt/nothrow1.C')
-rw-r--r--gcc/testsuite/g++.dg/opt/nothrow1.C25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/opt/nothrow1.C b/gcc/testsuite/g++.dg/opt/nothrow1.C
new file mode 100644
index 000000000..c1a80822b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/nothrow1.C
@@ -0,0 +1,25 @@
+// Test that the nothrow optimization works properly.
+// { dg-do compile }
+// { dg-options "-O -fdump-tree-optimized" }
+
+extern void blah() throw();
+
+int i, j, k;
+
+int main()
+{
+ try
+ {
+ ++i;
+ blah();
+ ++j;
+ }
+ catch (...)
+ {
+ return -42;
+ }
+}
+
+// The catch block should be optimized away.
+// { dg-final { scan-tree-dump-times "-42" 0 "optimized" } }
+// { dg-final { cleanup-tree-dump "optimized" } }