Home | History | Annotate | Download | only in SemaObjC
      1 // RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
      2 
      3 @class NSString;
      4 
      5 @interface A
      6 -t1 __attribute__((noreturn));
      7 - (NSString *)stringByAppendingFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2)));
      8 -(void) m0 __attribute__((noreturn));
      9 -(void) m1 __attribute__((unused));
     10 @end
     11 
     12 
     13 @interface INTF
     14 - (int) foo1: (int)arg1 __attribute__((deprecated));
     15 
     16 - (int) foo: (int)arg1;  // expected-note {{method 'foo:' declared here}}
     17 
     18 - (int) foo2: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)); // expected-note {{method 'foo2:' declared here}}
     19 - (int) foo3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) __attribute__((ns_consumes_self));
     20 @end
     21 
     22 @implementation INTF
     23 - (int) foo: (int)arg1  __attribute__((deprecated)){ // expected-warning {{attributes on method implementation and its declaration must match}}
     24         return 10;
     25 }
     26 - (int) foo1: (int)arg1 {
     27         return 10;
     28 }
     29 - (int) foo2: (int)arg1 __attribute__((deprecated)) {  // expected-warning {{attributes on method implementation and its declaration must match}}
     30         return 10;
     31 }
     32 - (int) foo3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) __attribute__((ns_consumes_self)) {return 0; }
     33 - (void) dep __attribute__((deprecated)) { } // OK private methodn
     34 @end
     35 
     36 
     37 // rdar://10529259
     38 #define IBAction void)__attribute__((ibaction)
     39 
     40 @interface Foo 
     41 - (void)doSomething1:(id)sender;
     42 - (void)doSomething2:(id)sender; // expected-note {{method 'doSomething2:' declared here}}
     43 @end
     44 
     45 @implementation Foo
     46 - (void)doSomething1:(id)sender{}
     47 - (void)doSomething2:(id)sender{}
     48 @end
     49 
     50 @interface Bar : Foo
     51 - (IBAction)doSomething1:(id)sender;
     52 @end
     53 @implementation Bar
     54 - (IBAction)doSomething1:(id)sender {}
     55 - (IBAction)doSomething2:(id)sender {} // expected-warning {{attributes on method implementation and its declaration must match}}
     56 - (IBAction)doSomething3:(id)sender {}
     57 @end
     58 
     59 // rdar://11593375
     60 @interface NSObject @end
     61 
     62 @interface Test : NSObject
     63 -(id)method __attribute__((deprecated));
     64 -(id)method1;
     65 -(id)method2 __attribute__((aligned(16)));
     66 - (id) method3: (int)arg1 __attribute__((aligned(16)))  __attribute__((deprecated)) __attribute__((unavailable)); // expected-note {{method 'method3:' declared here}}
     67 - (id) method4: (int)arg1 __attribute__((aligned(16)))  __attribute__((deprecated)) __attribute__((unavailable)); 
     68 @end
     69 
     70 @implementation Test
     71 -(id)method __attribute__((aligned(16))) __attribute__((aligned(16))) __attribute__((deprecated)) {
     72     return self;
     73 }
     74 -(id)method1 __attribute__((aligned(16))) {
     75     return self;
     76 }
     77 -(id)method2 {
     78     return self;
     79 }
     80 - (id) method3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) {  // expected-warning {{attributes on method implementation and its declaration must match}}
     81         return self;
     82 }
     83 - (id) method4: (int)arg1 __attribute__((aligned(16))) __attribute__((deprecated)) __attribute__((unavailable)) {
     84   return self;
     85 }
     86 @end
     87