| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
| 2 |
// pr8453 |
| 3 |
|
| 4 |
@protocol NSCopying @end |
| 5 |
@protocol NSPROTO @end |
| 6 |
@protocol NSPROTO1 @end |
| 7 |
@protocol NSPROTO2 @end |
| 8 |
|
| 9 |
@interface NSObject <NSCopying, NSPROTO, NSPROTO1> { |
| 10 |
Class isa; |
| 11 |
} |
| 12 |
@end |
| 13 |
|
| 14 |
void gorf(NSObject <NSCopying> *); // expected-note {{passing argument to parameter here}} |
| 15 |
|
| 16 |
NSObject <NSCopying> *foo(id <NSCopying> bar, id id_obj) |
| 17 |
{ |
| 18 |
NSObject <NSCopying> *Init = bar; // expected-warning {{initializing 'NSObject<NSCopying> *' with an expression of incompatible type 'id<NSCopying>'}} |
| 19 |
NSObject *Init1 = bar; // expected-warning {{initializing 'NSObject *' with an expression of incompatible type 'id<NSCopying>'}} |
| 20 |
|
| 21 |
NSObject <NSCopying> *I = id_obj; |
| 22 |
NSObject *I1 = id_obj; |
| 23 |
gorf(bar); // expected-warning {{passing 'id<NSCopying>' to parameter of incompatible type 'NSObject<NSCopying> *'}} |
| 24 |
|
| 25 |
gorf(id_obj); |
| 26 |
|
| 27 |
return bar; // expected-warning {{returning 'id<NSCopying>' from a function with incompatible result type 'NSObject<NSCopying> *'}} |
| 28 |
} |
| 29 |
|
| 30 |
void test(id <NSCopying, NSPROTO, NSPROTO2> bar) |
| 31 |
{ |
| 32 |
NSObject <NSCopying> *Init = bar; // expected-warning {{initializing 'NSObject<NSCopying> *' with an expression of incompatible type 'id<NSCopying,NSPROTO,NSPROTO2>'}} |
| 33 |
} |
| 34 |
|
| 35 |
@interface NSObject (CAT) |
| 36 |
+ (struct S*)Meth : (struct S*)arg; |
| 37 |
@end |
| 38 |
|
| 39 |
struct S { |
| 40 |
char *types; |
| 41 |
}; |
| 42 |
|
| 43 |
@interface I |
| 44 |
@end |
| 45 |
|
| 46 |
@implementation I |
| 47 |
- (struct S *)Meth : (struct S*)a { |
| 48 |
return [NSObject Meth : a]; |
| 49 |
} |
| 50 |
@end |