Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / obj-c++.dg / try-catch-1.mm
blobdb9b02f2acf1bb4a353b00bc2eb5048584751f1f
1 /* Test if the compiler accepts @throw / @try..@catch..@finally syntax.  */
2 /* Developed by Ziemowit Laski <zlaski@apple.com>.  */
4 /* { dg-options "-fobjc-exceptions" } */
5 /* { dg-do compile } */
7 #include <objc/Object.h>
8 #include <stdio.h>
9 #include <setjmp.h>
11 @interface Frob: Object
12 @end
14 @implementation Frob: Object
15 @end
17 static int exc_control = 0;
19 int proc() {
20   if(exc_control) {
21     printf ("Throwing (%d)... ", exc_control);
22     @throw [Frob new];
23   }
24   return 1;
27 int foo()
29   @try {
30     return proc();
31   }
32   @catch (Frob* ex) {
33     if(exc_control > 1) {
34       printf("Rethrowing (%d)... ", exc_control);
35       @throw;
36     }
37     return 0;
38   }
39   @finally {
40     printf("In @finally block (%d)... ", exc_control);
41   }