1/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */ 2/* { dg-do run } */ 3/* { dg-options "-fobjc-exceptions" } */ 4/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ 5 6/* This test checks the syntax @catch (...) which catches any 7 exceptions. Check that code using it runs correctly. */ 8 9#include "../objc-obj-c++-shared/TestsuiteObject.m" 10#include <stdlib.h> 11 12@interface MyObject : TestsuiteObject 13@end 14 15@implementation MyObject 16@end 17 18int test (id object) 19{ 20 int i = 0; 21 22 @try 23 { 24 @throw object; 25 } 26 @catch (MyObject *o) 27 { 28 i += 1; 29 } 30 @catch (...) 31 { 32 i += 2; 33 } 34 @finally 35 { 36 i += 4; 37 } 38 39 return i; 40} 41 42int main (void) 43{ 44 if (test ([MyObject new]) != 5) 45 abort (); 46 47 if (test ([TestsuiteObject new]) != 6) 48 abort (); 49 50 return 0; 51} 52