Home | History | Annotate | Download | only in SemaObjC
      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() {
     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 fiarly 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-warning{{incompatible pointer types sending 'NSObject *(NSObject *, NSObject *)' to parameter of type 'FuncSignature *'}}
     37 }
     38