Fariborz Jahanian | 566fff0 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
| 2 | // RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s |
| 4 | // RUN: %clang_cc1 -x objective-c++ -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s |
Fariborz Jahanian | 566fff0 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 5 | // rdar://6386358 |
Fariborz Jahanian | d6876b2 | 2012-09-10 18:04:25 +0000 | [diff] [blame] | 6 | |
| 7 | #if __has_attribute(objc_requires_super) |
| 8 | #define NS_REQUIRES_SUPER __attribute((objc_requires_super)) |
| 9 | #endif |
| 10 | |
Fariborz Jahanian | 566fff0 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 11 | @protocol NSObject // expected-note {{protocol is declared here}} |
Fariborz Jahanian | d6876b2 | 2012-09-10 18:04:25 +0000 | [diff] [blame] | 12 | - MyDealloc NS_REQUIRES_SUPER; // expected-warning {{'objc_requires_super' attribute cannot be applied to methods in protocols}} |
Fariborz Jahanian | 566fff0 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 13 | @end |
| 14 | |
| 15 | @interface Root |
| 16 | - MyDealloc __attribute((objc_requires_super)); |
| 17 | - (void)XXX __attribute((objc_requires_super)); |
| 18 | - (void) dealloc __attribute((objc_requires_super)); // expected-warning {{'objc_requires_super' attribute cannot be applied to dealloc}} |
Fariborz Jahanian | d6876b2 | 2012-09-10 18:04:25 +0000 | [diff] [blame] | 19 | - (void) MyDeallocMeth; // Method in root is not annotated. |
| 20 | - (void) AnnotMyDeallocMeth __attribute((objc_requires_super)); |
| 21 | - (void) AnnotMyDeallocMethCAT NS_REQUIRES_SUPER; |
Jordan Rose | 2afd661 | 2012-10-19 16:05:26 +0000 | [diff] [blame] | 22 | |
| 23 | + (void)registerClass:(id)name __attribute((objc_requires_super)); |
Fariborz Jahanian | 566fff0 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 24 | @end |
| 25 | |
| 26 | @interface Baz : Root<NSObject> |
| 27 | - MyDealloc; |
Fariborz Jahanian | d6876b2 | 2012-09-10 18:04:25 +0000 | [diff] [blame] | 28 | - (void) MyDeallocMeth __attribute((objc_requires_super)); // 'Baz' author has annotated method |
| 29 | - (void) AnnotMyDeallocMeth; // Annotated in root but not here. Annotation is inherited though |
| 30 | - (void) AnnotMeth __attribute((objc_requires_super)); // 'Baz' author has annotated method |
Fariborz Jahanian | 566fff0 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 31 | @end |
| 32 | |
| 33 | @implementation Baz |
| 34 | - MyDealloc { |
| 35 | [super MyDealloc]; |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | - (void)XXX { |
| 40 | [super MyDealloc]; |
Fariborz Jahanian | b05417e | 2012-09-10 16:51:09 +0000 | [diff] [blame] | 41 | } // expected-warning {{method possibly missing a [super XXX] call}} |
Fariborz Jahanian | d6876b2 | 2012-09-10 18:04:25 +0000 | [diff] [blame] | 42 | |
Fariborz Jahanian | ce4bbb2 | 2013-11-05 00:28:21 +0000 | [diff] [blame] | 43 | - (void) MyDeallocMeth {} |
Fariborz Jahanian | d6876b2 | 2012-09-10 18:04:25 +0000 | [diff] [blame] | 44 | - (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}} |
Fariborz Jahanian | ce4bbb2 | 2013-11-05 00:28:21 +0000 | [diff] [blame] | 45 | - (void) AnnotMeth{}; |
Jordan Rose | 2afd661 | 2012-10-19 16:05:26 +0000 | [diff] [blame] | 46 | |
| 47 | + (void)registerClass:(id)name {} // expected-warning {{method possibly missing a [super registerClass:] call}} |
Fariborz Jahanian | 566fff0 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 48 | @end |
| 49 | |
Fariborz Jahanian | d6876b2 | 2012-09-10 18:04:25 +0000 | [diff] [blame] | 50 | @interface Bar : Baz |
| 51 | @end |
| 52 | |
| 53 | @implementation Bar |
| 54 | - (void) MyDeallocMeth {} // expected-warning {{method possibly missing a [super MyDeallocMeth] call}} |
| 55 | - (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}} |
| 56 | - (void) AnnotMeth{}; // expected-warning {{method possibly missing a [super AnnotMeth] call}} |
| 57 | @end |
| 58 | |
| 59 | @interface Bar(CAT) |
| 60 | - (void) AnnotMyDeallocMethCAT; // Annotated in root but not here. Annotation is inherited though |
| 61 | - (void) AnnotMethCAT __attribute((objc_requires_super)); |
| 62 | @end |
| 63 | |
| 64 | @implementation Bar(CAT) |
| 65 | - (void) MyDeallocMeth {} // expected-warning {{method possibly missing a [super MyDeallocMeth] call}} |
| 66 | - (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}} |
| 67 | - (void) AnnotMeth{}; // expected-warning {{method possibly missing a [super AnnotMeth] call}} |
| 68 | - (void) AnnotMyDeallocMethCAT{}; // expected-warning {{method possibly missing a [super AnnotMyDeallocMethCAT] call}} |
Fariborz Jahanian | ce4bbb2 | 2013-11-05 00:28:21 +0000 | [diff] [blame] | 69 | - (void) AnnotMethCAT {}; |
Fariborz Jahanian | d6876b2 | 2012-09-10 18:04:25 +0000 | [diff] [blame] | 70 | @end |
Jordan Rose | 2afd661 | 2012-10-19 16:05:26 +0000 | [diff] [blame] | 71 | |
| 72 | |
| 73 | @interface Valid : Baz |
| 74 | @end |
| 75 | |
| 76 | @implementation Valid |
| 77 | |
| 78 | - (void)MyDeallocMeth { |
| 79 | [super MyDeallocMeth]; // no-warning |
| 80 | } |
| 81 | |
| 82 | |
| 83 | + (void)registerClass:(id)name { |
| 84 | [super registerClass:name]; // no-warning |
| 85 | } |
| 86 | |
| 87 | @end |
Fariborz Jahanian | db4fc28 | 2013-07-09 22:02:20 +0000 | [diff] [blame] | 88 | |
| 89 | // rdar://14251387 |
| 90 | #define IBAction void)__attribute__((ibaction) |
| 91 | |
| 92 | @interface UIViewController @end |
| 93 | |
| 94 | @interface ViewController : UIViewController |
| 95 | - (void) someMethodRequiringSuper NS_REQUIRES_SUPER; |
| 96 | - (IBAction) someAction; |
| 97 | - (IBAction) someActionRequiringSuper NS_REQUIRES_SUPER; |
| 98 | @end |
| 99 | |
| 100 | |
| 101 | @implementation ViewController |
| 102 | - (void) someMethodRequiringSuper |
| 103 | { |
Fariborz Jahanian | ce4bbb2 | 2013-11-05 00:28:21 +0000 | [diff] [blame] | 104 | } |
Fariborz Jahanian | db4fc28 | 2013-07-09 22:02:20 +0000 | [diff] [blame] | 105 | - (IBAction) someAction |
| 106 | { |
| 107 | } |
| 108 | - (IBAction) someActionRequiringSuper |
| 109 | { |
Fariborz Jahanian | ce4bbb2 | 2013-11-05 00:28:21 +0000 | [diff] [blame] | 110 | } |
| 111 | @end |
| 112 | |
| 113 | // rdar://15385981 |
| 114 | @interface Barn |
| 115 | - (void)openDoor __attribute__((objc_requires_super)); |
| 116 | @end |
| 117 | |
| 118 | @implementation Barn |
| 119 | - (void) openDoor |
| 120 | { |
| 121 | ; |
| 122 | } |
| 123 | @end |
| 124 | |
| 125 | @interface HorseBarn:Barn @end |
| 126 | |
| 127 | @implementation HorseBarn |
| 128 | - (void) openDoor |
| 129 | { |
| 130 | ; |
| 131 | } // expected-warning {{method possibly missing a [super openDoor] call}} |
Fariborz Jahanian | db4fc28 | 2013-07-09 22:02:20 +0000 | [diff] [blame] | 132 | @end |