| 1 |
/* Ensure that @try/@catch blocks do not mess with types of |
| 2 |
local objects (other than their volatile bits). */ |
| 3 |
|
| 4 |
/* { dg-options "-fobjc-exceptions" } */ |
| 5 |
/* { dg-do compile } */ |
| 6 |
|
| 7 |
#include "../objc-obj-c++-shared/TestsuiteObject.h" |
| 8 |
|
| 9 |
@protocol Proto1 |
| 10 |
- (int)meth1; |
| 11 |
@end |
| 12 |
|
| 13 |
@protocol Proto2 |
| 14 |
- (int)meth2; |
| 15 |
@end |
| 16 |
|
| 17 |
@interface MyClass: TestsuiteObject <Proto2> { |
| 18 |
int a; |
| 19 |
} |
| 20 |
- (int)meth2; |
| 21 |
- (TestsuiteObject *)parm1: (id)p1 parm2: (id<Proto1>)p2; |
| 22 |
@end |
| 23 |
|
| 24 |
MyClass *mc1, *mc2; |
| 25 |
|
| 26 |
@implementation MyClass |
| 27 |
- (int)meth2 { |
| 28 |
return a; |
| 29 |
} |
| 30 |
- (TestsuiteObject *)parm1: (id)p1 parm2: (id<Proto1>)p2 { |
| 31 |
@try { |
| 32 |
mc2 = p2; /* { dg-warning "type .id <Proto1>. does not conform to the .Proto2. protocol" } */ |
| 33 |
} |
| 34 |
@catch (id exc) { |
| 35 |
return exc; |
| 36 |
} |
| 37 |
mc1 = p1; /* no warning here! */ |
| 38 |
return self; |
| 39 |
} |
| 40 |
@end |