| 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 |
| 5 |
|
| 6 |
#if __has_attribute(objc_requires_super) |
| 7 |
#define NS_REQUIRES_SUPER __attribute((objc_requires_super)) |
| 8 |
#endif |
| 9 |
|
| 10 |
@protocol NSObject // expected-note {{protocol is declared here}} |
| 11 |
- MyDealloc NS_REQUIRES_SUPER; // expected-warning {{'objc_requires_super' attribute cannot be applied to methods in protocols}} |
| 12 |
@end |
| 13 |
|
| 14 |
@interface Root |
| 15 |
- MyDealloc __attribute((objc_requires_super)); |
| 16 |
- (void)XXX __attribute((objc_requires_super)); |
| 17 |
- (void) dealloc __attribute((objc_requires_super)); // expected-warning {{'objc_requires_super' attribute cannot be applied to dealloc}} |
| 18 |
- (void) MyDeallocMeth; // Method in root is not annotated. |
| 19 |
- (void) AnnotMyDeallocMeth __attribute((objc_requires_super)); |
| 20 |
- (void) AnnotMyDeallocMethCAT NS_REQUIRES_SUPER; |
| 21 |
|
| 22 |
+ (void)registerClass:(id)name __attribute((objc_requires_super)); |
| 23 |
@end |
| 24 |
|
| 25 |
@interface Baz : Root<NSObject> |
| 26 |
- MyDealloc; |
| 27 |
- (void) MyDeallocMeth __attribute((objc_requires_super)); // 'Baz' author has annotated method |
| 28 |
- (void) AnnotMyDeallocMeth; // Annotated in root but not here. Annotation is inherited though |
| 29 |
- (void) AnnotMeth __attribute((objc_requires_super)); // 'Baz' author has annotated method |
| 30 |
@end |
| 31 |
|
| 32 |
@implementation Baz |
| 33 |
- MyDealloc { |
| 34 |
[super MyDealloc]; |
| 35 |
return 0; |
| 36 |
} |
| 37 |
|
| 38 |
- (void)XXX { |
| 39 |
[super MyDealloc]; |
| 40 |
} // expected-warning {{method possibly missing a [super XXX] call}} |
| 41 |
|
| 42 |
- (void) MyDeallocMeth {} |
| 43 |
- (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}} |
| 44 |
- (void) AnnotMeth{}; |
| 45 |
|
| 46 |
+ (void)registerClass:(id)name {} // expected-warning {{method possibly missing a [super registerClass:] call}} |
| 47 |
@end |
| 48 |
|
| 49 |
@interface Bar : Baz |
| 50 |
@end |
| 51 |
|
| 52 |
@implementation Bar |
| 53 |
- (void) MyDeallocMeth {} // expected-warning {{method possibly missing a [super MyDeallocMeth] call}} |
| 54 |
- (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}} |
| 55 |
- (void) AnnotMeth{}; // expected-warning {{method possibly missing a [super AnnotMeth] call}} |
| 56 |
@end |
| 57 |
|
| 58 |
@interface Bar(CAT) |
| 59 |
- (void) AnnotMyDeallocMethCAT; // Annotated in root but not here. Annotation is inherited though |
| 60 |
- (void) AnnotMethCAT __attribute((objc_requires_super)); |
| 61 |
@end |
| 62 |
|
| 63 |
@implementation Bar(CAT) |
| 64 |
- (void) MyDeallocMeth {} // expected-warning {{method possibly missing a [super MyDeallocMeth] call}} |
| 65 |
- (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}} |
| 66 |
- (void) AnnotMeth{}; // expected-warning {{method possibly missing a [super AnnotMeth] call}} |
| 67 |
- (void) AnnotMyDeallocMethCAT{}; // expected-warning {{method possibly missing a [super AnnotMyDeallocMethCAT] call}} |
| 68 |
- (void) AnnotMethCAT {}; |
| 69 |
@end |
| 70 |
|
| 71 |
|
| 72 |
@interface Valid : Baz |
| 73 |
@end |
| 74 |
|
| 75 |
@implementation Valid |
| 76 |
|
| 77 |
- (void)MyDeallocMeth { |
| 78 |
[super MyDeallocMeth]; // no-warning |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
+ (void)registerClass:(id)name { |
| 83 |
[super registerClass:name]; // no-warning |
| 84 |
} |
| 85 |
|
| 86 |
@end |
| 87 |
|
| 88 |
@interface UIViewController @end |
| 89 |
|
| 90 |
@interface ViewController : UIViewController |
| 91 |
- (void) someMethodRequiringSuper NS_REQUIRES_SUPER; |
| 92 |
- (IBAction) someAction; |
| 93 |
- (IBAction) someActionRequiringSuper NS_REQUIRES_SUPER; |
| 94 |
@end |
| 95 |
|
| 96 |
|
| 97 |
@implementation ViewController |
| 98 |
- (void) someMethodRequiringSuper |
| 99 |
{ |
| 100 |
} |
| 101 |
- (IBAction) someAction |
| 102 |
{ |
| 103 |
} |
| 104 |
- (IBAction) someActionRequiringSuper |
| 105 |
{ |
| 106 |
} |
| 107 |
@end |
| 108 |
|
| 109 |
@interface Barn |
| 110 |
- (void)openDoor __attribute__((objc_requires_super)); |
| 111 |
@end |
| 112 |
|
| 113 |
@implementation Barn |
| 114 |
- (void) openDoor |
| 115 |
{ |
| 116 |
; |
| 117 |
} |
| 118 |
@end |
| 119 |
|
| 120 |
@interface HorseBarn:Barn @end |
| 121 |
|
| 122 |
@implementation HorseBarn |
| 123 |
- (void) openDoor |
| 124 |
{ |
| 125 |
; |
| 126 |
} // expected-warning {{method possibly missing a [super openDoor] call}} |
| 127 |
@end |