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
7 #if __has_attribute(objc_requires_super)
8 #define NS_REQUIRES_SUPER __attribute((objc_requires_super))
11 @protocol NSObject // expected-note {{protocol is declared here}}
12 - MyDealloc NS_REQUIRES_SUPER; // expected-warning {{'objc_requires_super' attribute cannot be applied to methods in protocols}}
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}}
19 - (void) MyDeallocMeth; // Method in root is not annotated.
20 - (void) AnnotMyDeallocMeth __attribute((objc_requires_super));
21 - (void) AnnotMyDeallocMethCAT NS_REQUIRES_SUPER;
23 + (void)registerClass:(id)name __attribute((objc_requires_super));
26 @interface Baz : Root<NSObject>
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
41 } // expected-warning {{method possibly missing a [super XXX] call}}
43 - (void) MyDeallocMeth {}
44 - (void) AnnotMyDeallocMeth{} // expected-warning {{method possibly missing a [super AnnotMyDeallocMeth] call}}
47 + (void)registerClass:(id)name {} // expected-warning {{method possibly missing a [super registerClass:] call}}
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}}
60 - (void) AnnotMyDeallocMethCAT; // Annotated in root but not here. Annotation is inherited though
61 - (void) AnnotMethCAT __attribute((objc_requires_super));
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}}
69 - (void) AnnotMethCAT {};
73 @interface Valid : Baz
78 - (void)MyDeallocMeth {
79 [super MyDeallocMeth]; // no-warning
83 + (void)registerClass:(id)name {
84 [super registerClass:name]; // no-warning
90 #define IBAction void)__attribute__((ibaction)
92 @interface UIViewController @end
94 @interface ViewController : UIViewController
95 - (void) someMethodRequiringSuper NS_REQUIRES_SUPER;
96 - (IBAction) someAction;
97 - (IBAction) someActionRequiringSuper NS_REQUIRES_SUPER;
101 @implementation ViewController
102 - (void) someMethodRequiringSuper
105 - (IBAction) someAction
108 - (IBAction) someActionRequiringSuper
115 - (void)openDoor __attribute__((objc_requires_super));
125 @interface HorseBarn:Barn @end
127 @implementation HorseBarn
131 } // expected-warning {{method possibly missing a [super openDoor] call}}