Fariborz Jahanian | 4053946 | 2012-03-16 16:52:06 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp |
Fariborz Jahanian | 55261af | 2012-03-19 18:11:32 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp |
| 3 | |
| 4 | typedef struct objc_class *Class; |
| 5 | typedef struct objc_object { |
| 6 | Class isa; |
| 7 | } *id; |
Fariborz Jahanian | 4053946 | 2012-03-16 16:52:06 +0000 | [diff] [blame] | 8 | |
| 9 | void *sel_registerName(const char *); |
| 10 | |
| 11 | @interface Foo @end |
| 12 | void TRY(); |
| 13 | void SPLATCH(); |
| 14 | void MYTRY(); |
| 15 | void MYCATCH(); |
| 16 | |
| 17 | void foo() { |
| 18 | @try { TRY(); } |
| 19 | @catch (...) { SPLATCH(); @throw; } |
| 20 | } |
| 21 | |
| 22 | int main() |
| 23 | { |
| 24 | |
| 25 | @try { |
| 26 | MYTRY(); |
| 27 | } |
| 28 | |
| 29 | @catch (Foo* localException) { |
| 30 | MYCATCH(); |
| 31 | @throw localException; |
| 32 | } |
| 33 | |
| 34 | // no catch clause |
| 35 | @try { } |
| 36 | @finally { } |
| 37 | } |
| 38 | |
| 39 | |
| 40 | @interface INST |
| 41 | { |
| 42 | INST* throw_val; |
| 43 | } |
| 44 | |
| 45 | - (id) ThrowThis; |
| 46 | |
| 47 | - (void) MainMeth; |
| 48 | |
| 49 | @end |
| 50 | |
| 51 | |
| 52 | @implementation INST |
| 53 | - (id) ThrowThis { return 0; } |
| 54 | |
| 55 | - (void) MainMeth { |
| 56 | @try { |
| 57 | MYTRY(); |
| 58 | } |
| 59 | @catch (Foo* localException) { |
| 60 | MYCATCH(); |
| 61 | @throw [self ThrowThis]; |
| 62 | } |
| 63 | @catch (...) { |
| 64 | @throw [throw_val ThrowThis]; |
| 65 | } |
| 66 | } |
| 67 | @end |
Fariborz Jahanian | a09cd81 | 2013-02-11 19:30:33 +0000 | [diff] [blame] | 68 | |
| 69 | // rdar://13186010 |
| 70 | @class NSDictionary, NSException; |
| 71 | @class NSMutableDictionary; |
| 72 | |
| 73 | @interface NSString |
| 74 | + (id)stringWithFormat:(NSString *)format, ... ; |
| 75 | @end |
| 76 | |
| 77 | @interface NSException |
| 78 | + (NSException *)exceptionWithName:(NSString *)name reason:(NSString *)reason userInfo:(NSDictionary *)userInfo; |
| 79 | @end |
| 80 | id *_imp__NSInvalidArgumentException; |
| 81 | |
| 82 | @interface NSSetExpression @end |
| 83 | |
| 84 | @implementation NSSetExpression |
| 85 | -(id)expressionValueWithObject:(id)object context:(NSMutableDictionary*)bindings { |
| 86 | id leftSet; |
| 87 | id rightSet; |
| 88 | @throw [NSException exceptionWithName: *_imp__NSInvalidArgumentException reason: [NSString stringWithFormat: @"Can't evaluate set expression; left subexpression not a set (lhs = %@ rhs = %@)", leftSet, rightSet] userInfo: 0]; |
| 89 | |
| 90 | return leftSet ; |
| 91 | } |
| 92 | @end |
| 93 | |