| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s |
| 2 |
|
| 3 |
@protocol NSObject |
| 4 |
@end |
| 5 |
@interface NSObject <NSObject> { |
| 6 |
} |
| 7 |
@end |
| 8 |
@interface NSString : NSObject |
| 9 |
@end |
| 10 |
void __setRetained(id *ivar, id value, NSObject **o) { |
| 11 |
*ivar = value; |
| 12 |
} |
| 13 |
static NSString *_logProcessPrefix = 0; |
| 14 |
void func(void) { |
| 15 |
__setRetained(&_logProcessPrefix, _logProcessPrefix, &_logProcessPrefix); |
| 16 |
} |
| 17 |
@implementation NSObject (ScopeAdditions) |
| 18 |
+ (void)setObjectLogProcessPrefix:(NSString *)processPrefix { |
| 19 |
__setRetained(&_logProcessPrefix, processPrefix, &_logProcessPrefix); |
| 20 |
} |
| 21 |
@end |
| 22 |
|
| 23 |
@class Derived; |
| 24 |
|
| 25 |
NSObject *ExternFunc (NSObject *filePath, NSObject *key); |
| 26 |
typedef id FuncSignature (NSObject *arg1, Derived *arg2); |
| 27 |
|
| 28 |
@interface Derived: NSObject |
| 29 |
+ (void)registerFunc:(FuncSignature *)function; // expected-note{{passing argument to parameter 'function' here}} |
| 30 |
@end |
| 31 |
|
| 32 |
void foo(void) |
| 33 |
{ |
| 34 |
// GCC currently allows this (it has some fairly new support for covariant return types and contravariant argument types). |
| 35 |
// Since registerFunc: expects a Derived object as it's second argument, I don't know why this would be legal. |
| 36 |
[Derived registerFunc: ExternFunc]; // expected-error{{incompatible function pointer types sending 'NSObject *(NSObject *, NSObject *)' to parameter of type 'FuncSignature *' (aka 'id (*)(NSObject *, Derived *)')}} |
| 37 |
} |
| 38 |
|
| 39 |
@protocol NSCopying @end |
| 40 |
@interface I |
| 41 |
- (void) Meth : (id <NSCopying>)aKey; // expected-note {{passing argument to parameter 'aKey' here}} |
| 42 |
@end |
| 43 |
|
| 44 |
@class ForwarClass; // expected-note 3 {{conformance of forward class 'ForwarClass' to protocol 'NSCopying' cannot be confirmed}} |
| 45 |
|
| 46 |
ForwarClass *Test10751015 (I* pi, ForwarClass *ns_forward) { |
| 47 |
|
| 48 |
[pi Meth : ns_forward ]; // expected-warning {{sending 'ForwarClass *' to parameter of incompatible type 'id<NSCopying>'}} |
| 49 |
|
| 50 |
id <NSCopying> id_ns = ns_forward; // expected-warning {{initializing 'id<NSCopying>' with an expression of incompatible type 'ForwarClass *'}} |
| 51 |
|
| 52 |
return id_ns; // expected-warning {{returning 'id<NSCopying>' from a function with incompatible result type 'ForwarClass *'}} |
| 53 |
} |