diff options
author | Bernd Schmidt <bernd.schmidt@analog.com> | 2006-02-06 16:36:35 +0000 |
---|---|---|
committer | Bernd Schmidt <bernd.schmidt@analog.com> | 2006-02-06 16:36:35 +0000 |
commit | b3d13cd7ae392041004db6b9bf5098372048c00e (patch) | |
tree | 2adf45987dc9f88c26eeb95b0071647ebb5c87ec /gcc/testsuite/obj-c++.dg/try-catch-1.mm | |
parent | 337db89251de80f8ff7a00b2d71bc333c630b6e4 (diff) |
Merge reload-branch up to revision 101000reload-branch
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/reload-branch@110651 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/obj-c++.dg/try-catch-1.mm')
-rw-r--r-- | gcc/testsuite/obj-c++.dg/try-catch-1.mm | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/testsuite/obj-c++.dg/try-catch-1.mm b/gcc/testsuite/obj-c++.dg/try-catch-1.mm new file mode 100644 index 00000000000..db9b02f2acf --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/try-catch-1.mm @@ -0,0 +1,42 @@ +/* Test if the compiler accepts @throw / @try..@catch..@finally syntax. */ +/* Developed by Ziemowit Laski <zlaski@apple.com>. */ + +/* { dg-options "-fobjc-exceptions" } */ +/* { dg-do compile } */ + +#include <objc/Object.h> +#include <stdio.h> +#include <setjmp.h> + +@interface Frob: Object +@end + +@implementation Frob: Object +@end + +static int exc_control = 0; + +int proc() { + if(exc_control) { + printf ("Throwing (%d)... ", exc_control); + @throw [Frob new]; + } + return 1; +} + +int foo() +{ + @try { + return proc(); + } + @catch (Frob* ex) { + if(exc_control > 1) { + printf("Rethrowing (%d)... ", exc_control); + @throw; + } + return 0; + } + @finally { + printf("In @finally block (%d)... ", exc_control); + } +} |