Home | History | Annotate | Download | only in SemaObjC
      1 // RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
      2 // RUN: %clang_cc1 -x objective-c++ -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
      3 
      4 @interface A @end
      5 @interface B : A @end
      6 
      7 @interface Test1 {}
      8 - (void) test1:(A*) object; // expected-note {{previous definition is here}} 
      9 - (void) test2:(B*) object;
     10 @end
     11 
     12 @implementation Test1
     13 - (void) test1:(B*) object {} // expected-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}}
     14 - (void) test2:(A*) object {}
     15 @end
     16 
     17 @interface Test2 {}
     18 - (void) test1:(id) object; // expected-note {{previous definition is here}} 
     19 - (void) test2:(A*) object;
     20 @end
     21 
     22 @implementation Test2
     23 - (void) test1:(A*) object {} // expected-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}}
     24 - (void) test2:(id) object {}
     25 @end
     26 
     27 @interface Test3 {}
     28 - (A*) test1;
     29 - (B*) test2; // expected-note {{previous definition is here}} 
     30 @end
     31 
     32 @implementation Test3
     33 - (B*) test1 { return 0; }
     34 - (A*) test2 { return 0; } // expected-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}}
     35 @end
     36 
     37 // The particular case of overriding with an id return is white-listed.
     38 @interface Test4 {}
     39 - (id) test1;
     40 - (A*) test2;
     41 @end
     42 @implementation Test4
     43 - (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987
     44 - (id) test2 { return 0; }
     45 @end
     46 
     47 // rdar://12522752
     48 typedef int int32_t;
     49 typedef long long int64_t;
     50 
     51 @interface NSObject @end
     52 
     53 @protocol CKMessage
     54 @property (nonatomic,readonly,assign) int64_t sequenceNumber; // expected-note {{previous definition is here}}
     55 @end
     56 
     57 @protocol CKMessage;
     58 
     59 @interface CKIMMessage : NSObject<CKMessage>
     60 @end
     61 
     62 @implementation CKIMMessage
     63 - (int32_t)sequenceNumber { // expected-warning {{conflicting return type in implementation of 'sequenceNumber': 'int64_t' (aka 'long long') vs 'int32_t' (aka 'int')}}
     64   return 0;
     65 }
     66 @end
     67