1/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ 2 3/* FIXME: This does not test running the code, because Objective-C exceptions at the moment 4 do not execute correctly in Objective-C++. See PR objc++/23616. Once that is fixed, 5 this test should be changed to use 'dg-do run' instead of just 'dg-do compile'. */ 6/* { dg-do compile } */ 7/* { dg-options "-fobjc-exceptions" } */ 8 9/* This test checks the syntax @catch (...) which catches any 10 exceptions. Check that code using it runs correctly. */ 11 12#include "../objc-obj-c++-shared/TestsuiteObject.m" 13#include <stdlib.h> 14 15@interface MyObject : TestsuiteObject 16@end 17 18@implementation MyObject 19@end 20 21int test (id object) 22{ 23 int i = 0; 24 25 @try 26 { 27 @throw object; 28 } 29 @catch (MyObject *o) 30 { 31 i += 1; 32 } 33 @catch (...) 34 { 35 i += 2; 36 } 37 @finally 38 { 39 i += 4; 40 } 41 42 return i; 43} 44 45int main (void) 46{ 47 if (test ([MyObject new]) != 5) 48 abort (); 49 50 if (test ([TestsuiteObject new]) != 6) 51 abort (); 52 53 return 0; 54} 55