1#include "Test.h" 2#include "../unwind.h" 3 4#if __cplusplus 5#error This is not an ObjC++ test! 6#endif 7 8struct 9{ 10 struct _Unwind_Exception header; 11 id x; 12} foreign_exception; 13 14BOOL finally_called = NO; 15 16id e1; 17void throw_id(void) 18{ 19 @throw e1; 20} 21 22void throw_int(void); 23int catchall(void); 24 25 26void finally(void) 27{ 28 @try 29 { 30 throw_int(); 31 } 32 @finally 33 { 34 finally_called = YES; 35 } 36 finally_called = NO; 37} 38 39 40int main(void) 41{ 42 BOOL catchall_entered = NO; 43 BOOL catchid = YES; 44 e1 = [Test new]; 45 @try 46 { 47 finally(); 48 } 49 @catch (id x) 50 { 51 assert(0); 52 } 53 @catch(...) 54 { 55 catchall_entered = YES; 56 } 57 assert(finally_called == YES); 58 assert(catchall_entered == YES); 59 @try 60 { 61 catchall(); 62 } 63 @catch (id x) 64 { 65 assert(x == e1); 66 } 67 assert(catchid == YES); 68 [e1 dealloc]; 69 return 0; 70} 71