1/* Area: ffi_call 2 Purpose: Check raising/catching exceptions 3 Limitations: none. 4 PR: none. 5 Originator: Ronald Oussoren */ 6 7/* { dg-do run } */ 8#include "ffitest.h" 9#import <Foundation/Foundation.h> 10 11static void raiseit(void) 12{ 13 [NSException raise:NSInvalidArgumentException format:@"Dummy exception"]; 14} 15 16int main (void) 17{ 18 ffi_cif cif; 19 ffi_type *args[MAX_ARGS]; 20 void *values[MAX_ARGS]; 21 int ok; 22 23 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 24 25 26 /* Initialize the cif */ 27 CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, 28 &ffi_type_void, args) == FFI_OK); 29 30 ok = 0; 31 NS_DURING 32 ffi_call(&cif, FFI_FN(raiseit), NULL, values); 33 NS_HANDLER 34 ok = 1; 35 36 NS_ENDHANDLER 37 38 CHECK(ok); 39 40 [pool release]; 41 exit(0); 42 43} 44