| 1 |
/* Test if the compiler accepts @throw / @try..@catch..@finally syntax. */ |
| 2 |
/* Developed by Ziemowit Laski <[email protected]>. */ |
| 3 |
/* { dg-options "-fobjc-exceptions" } */ |
| 4 |
/* { dg-do compile } */ |
| 5 |
|
| 6 |
#include "../objc-obj-c++-shared/TestsuiteObject.h" |
| 7 |
#include <stdio.h> |
| 8 |
#include <setjmp.h> |
| 9 |
|
| 10 |
@interface Frob: TestsuiteObject |
| 11 |
@end |
| 12 |
|
| 13 |
@implementation Frob: TestsuiteObject |
| 14 |
@end |
| 15 |
|
| 16 |
static int exc_control = 0; |
| 17 |
|
| 18 |
int proc() { |
| 19 |
if(exc_control) { |
| 20 |
printf ("Throwing (%d)... ", exc_control); |
| 21 |
@throw [Frob new]; |
| 22 |
} |
| 23 |
return 1; |
| 24 |
} |
| 25 |
|
| 26 |
int foo() |
| 27 |
{ |
| 28 |
@try { |
| 29 |
return proc(); |
| 30 |
} |
| 31 |
@catch (Frob* ex) { |
| 32 |
if(exc_control > 1) { |
| 33 |
printf("Rethrowing (%d)... ", exc_control); |
| 34 |
@throw; |
| 35 |
} |
| 36 |
return 0; |
| 37 |
} |
| 38 |
@finally { |
| 39 |
printf("In @finally block (%d)... ", exc_control); |
| 40 |
} |
| 41 |
} |