Fariborz Jahanian | 8410113 | 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 | 8410113 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 5 | // rdar://6386358 |
Fariborz Jahanian | 6f93860 | 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 | 8410113 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 11 | @protocol NSObject // expected-note {{protocol is declared here}} |
Fariborz Jahanian | 6f93860 | 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 | 8410113 | 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 | 6f93860 | 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; |
Fariborz Jahanian | 8410113 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 22 | @end |
| 23 | |
| 24 | @interface Baz : Root<NSObject> |
| 25 | - MyDealloc; |
Fariborz Jahanian | 6f93860 | 2012-09-10 18:04:25 +0000 | [diff] [blame^] | 26 | - (void) MyDeallocMeth __attribute((objc_requires_super)); // 'Baz' author has annotated method |
| 27 | - (void) AnnotMyDeallocMeth; // Annotated in root but not here. Annotation is inherited though |
| 28 | - (void) AnnotMeth __attribute((objc_requires_super)); // 'Baz' author has annotated method |
Fariborz Jahanian | 8410113 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 29 | @end |
| 30 | |
| 31 | @implementation Baz |
| 32 | - MyDealloc { |
| 33 | [super MyDealloc]; |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | - (void)XXX { |
| 38 | [super MyDealloc]; |
Fariborz Jahanian | 9f55983 | 2012-09-10 16:51:09 +0000 | [diff] [blame] | 39 | } // expected-warning {{method possibly missing a [super XXX] call}} |
Fariborz Jahanian | 6f93860 | 2012-09-10 18:04:25 +0000 | [diff] [blame^] | 40 | |
| 41 | - (void) MyDeallocMeth {} // No warning here. |
| 42 | - (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}} |
| 43 | - (void) AnnotMeth{}; // No warning here. Annotation is in its class. |
Fariborz Jahanian | 8410113 | 2012-09-07 23:46:23 +0000 | [diff] [blame] | 44 | @end |
| 45 | |
Fariborz Jahanian | 6f93860 | 2012-09-10 18:04:25 +0000 | [diff] [blame^] | 46 | @interface Bar : Baz |
| 47 | @end |
| 48 | |
| 49 | @implementation Bar |
| 50 | - (void) MyDeallocMeth {} // expected-warning {{method possibly missing a [super MyDeallocMeth] call}} |
| 51 | - (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}} |
| 52 | - (void) AnnotMeth{}; // expected-warning {{method possibly missing a [super AnnotMeth] call}} |
| 53 | @end |
| 54 | |
| 55 | @interface Bar(CAT) |
| 56 | - (void) AnnotMyDeallocMethCAT; // Annotated in root but not here. Annotation is inherited though |
| 57 | - (void) AnnotMethCAT __attribute((objc_requires_super)); |
| 58 | @end |
| 59 | |
| 60 | @implementation Bar(CAT) |
| 61 | - (void) MyDeallocMeth {} // expected-warning {{method possibly missing a [super MyDeallocMeth] call}} |
| 62 | - (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}} |
| 63 | - (void) AnnotMeth{}; // expected-warning {{method possibly missing a [super AnnotMeth] call}} |
| 64 | - (void) AnnotMyDeallocMethCAT{}; // expected-warning {{method possibly missing a [super AnnotMyDeallocMethCAT] call}} |
| 65 | - (void) AnnotMethCAT {}; |
| 66 | @end |