1/* Test if the compiler accepts @throw / @try..@catch..@finally syntax. */ 2/* Developed by Ziemowit Laski <zlaski@apple.com>. */ 3 4/* { dg-options "-fobjc-exceptions" } */ 5/* { dg-do compile } */ 6 7#include "../objc-obj-c++-shared/TestsuiteObject.h" 8#include <stdio.h> 9#include <setjmp.h> 10 11@interface Frob: TestsuiteObject 12@end 13 14@implementation Frob: TestsuiteObject 15@end 16 17static int exc_control = 0; 18 19int proc() { 20 if(exc_control) { 21 printf ("Throwing (%d)... ", exc_control); 22 @throw [Frob new]; 23 } 24 return 1; 25} 26 27int foo() 28{ 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 } 42 return -1; 43} 44