brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.7 KiB · 7e3864e Raw
128 lines · plain
1// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s2// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s3// RUN: %clang_cc1  -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s4// RUN: %clang_cc1 -x objective-c++ -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s5 6#if __has_attribute(objc_requires_super)7#define  NS_REQUIRES_SUPER __attribute((objc_requires_super))8#endif9 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@end13 14@interface Root15- 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@end24 25@interface Baz : Root<NSObject>26- MyDealloc;27- (void) MyDeallocMeth __attribute((objc_requires_super)); // 'Baz' author has annotated method28- (void) AnnotMyDeallocMeth; // Annotated in root but not here. Annotation is inherited though29- (void) AnnotMeth __attribute((objc_requires_super)); // 'Baz' author has annotated method30@end31 32@implementation Baz33-  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@end48 49@interface Bar : Baz50@end51 52@implementation Bar53- (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@end57 58@interface Bar(CAT) 59- (void) AnnotMyDeallocMethCAT; // Annotated in root but not here. Annotation is inherited though60- (void) AnnotMethCAT __attribute((objc_requires_super));61@end62 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@end70 71 72@interface Valid : Baz73@end74 75@implementation Valid76 77- (void)MyDeallocMeth {78  [super MyDeallocMeth]; // no-warning79}80 81 82+ (void)registerClass:(id)name {83  [super registerClass:name]; // no-warning84}85 86@end87 88@interface UIViewController @end89 90@interface ViewController : UIViewController91- (void) someMethodRequiringSuper NS_REQUIRES_SUPER;92- (IBAction) someAction;93- (IBAction) someActionRequiringSuper NS_REQUIRES_SUPER;94@end95 96 97@implementation ViewController98- (void) someMethodRequiringSuper99{100}101- (IBAction) someAction102{103}104- (IBAction) someActionRequiringSuper105{106} 107@end108 109@interface Barn110- (void)openDoor __attribute__((objc_requires_super));111@end112 113@implementation Barn114- (void) openDoor115{116    ;117}118@end119 120@interface HorseBarn:Barn @end121 122@implementation HorseBarn123- (void) openDoor124{125    ;126}	// expected-warning {{method possibly missing a [super openDoor] call}}127@end128