1 // RUN: %clang_cc1 %s -Wpotentially-direct-selector -verify
2 // RUN: %clang_cc1 %s -Wstrict-potentially-direct-selector -verify=expected,strict
4 #define NS_DIRECT __attribute__((objc_direct))
6 __attribute__((objc_root_class))
15 -(void)inDerivedCatImpl;
17 +(void)inDerivedClass;
18 +(void)inDerivedCatClass;
21 __attribute__((objc_root_class))
23 -(void)inBase NS_DIRECT; // expected-note + {{direct method}}
24 +(void)inBaseClass NS_DIRECT; // expected-note + {{direct method}}
28 -(void)inBaseImpl NS_DIRECT { // expected-note + {{direct method}}
35 -(void)inBaseCat NS_DIRECT; // expected-note + {{direct method}}
38 @implementation Base (Cat)
39 -(void)inBaseCatImpl NS_DIRECT { // expected-note + {{direct method}}
44 @interface Derived : Base
45 -(void)inDerived NS_DIRECT; // expected-note + {{direct method}}
46 +(void)inDerivedClass NS_DIRECT; // expected-note + {{direct method}}
49 @implementation Derived
50 -(void)inDerivedImpl NS_DIRECT { // expected-note + {{direct method}}
53 +(void)inDerivedClass {}
56 @interface Derived (Cat)
57 -(void)inDerivedCat NS_DIRECT; // expected-note + {{direct method}}
58 +(void)inDerivedCatClass NS_DIRECT; // expected-note + {{direct method}}
61 @implementation Derived (Cat)
62 -(void)inDerivedCatImpl NS_DIRECT { // expected-note + {{direct method}}
64 -(void)inDerivedCat {}
65 +(void)inDerivedCatClass {}
68 (void)@selector(inBase); // expected-warning{{@selector expression formed with potentially direct selector}}
69 (void)@selector(inBaseImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
70 (void)@selector(inBaseCat); // expected-warning{{@selector expression formed with potentially direct selector}}
71 (void)@selector(inBaseCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
72 (void)@selector(inDerived); // expected-warning{{@selector expression formed with potentially direct selector}}
73 (void)@selector(inDerivedImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
74 (void)@selector(inDerivedCat); // expected-warning{{@selector expression formed with potentially direct selector}}
75 (void)@selector(inDerivedCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
76 (void)@selector(inDerivedClass); // expected-warning{{@selector expression formed with potentially direct selector}}
77 (void)@selector(inBaseClass); // expected-warning{{@selector expression formed with potentially direct selector}}
78 (void)@selector(inDerivedCatClass); // expected-warning{{@selector expression formed with potentially direct selector}}
83 (void)@selector(inBase); // strict-warning{{@selector expression formed with potentially direct selector}}
84 (void)@selector(inBaseImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
85 (void)@selector(inBaseCat); // strict-warning{{@selector expression formed with potentially direct selector}}
86 (void)@selector(inBaseCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
87 (void)@selector(inDerived); // strict-warning{{@selector expression formed with potentially direct selector}}
88 (void)@selector(inDerivedImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
89 (void)@selector(inDerivedCat); // strict-warning{{@selector expression formed with potentially direct selector}}
90 (void)@selector(inDerivedCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
91 (void)@selector(inDerivedClass); // strict-warning{{@selector expression formed with potentially direct selector}}
92 (void)@selector(inBaseClass); // strict-warning{{@selector expression formed with potentially direct selector}}
93 (void)@selector(inDerivedCatClass); // strict-warning{{@selector expression formed with potentially direct selector}}
96 @interface OnlyBase : Base @end
97 @implementation OnlyBase
99 (void)@selector(inBase); // expected-warning{{@selector expression formed with potentially direct selector}}
100 (void)@selector(inBaseImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
101 (void)@selector(inBaseCat); // expected-warning{{@selector expression formed with potentially direct selector}}
102 (void)@selector(inBaseCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
103 (void)@selector(inDerived); // strict-warning{{@selector expression formed with potentially direct selector}}
104 (void)@selector(inDerivedImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
105 (void)@selector(inDerivedCat); // strict-warning{{@selector expression formed with potentially direct selector}}
106 (void)@selector(inDerivedCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
107 (void)@selector(inDerivedClass); // strict-warning{{@selector expression formed with potentially direct selector}}
108 (void)@selector(inBaseClass); // expected-warning{{@selector expression formed with potentially direct selector}}
109 (void)@selector(inDerivedCatClass); // strict-warning{{@selector expression formed with potentially direct selector}}
113 __attribute__((objc_root_class))
114 @interface Unrelated @end
115 @implementation Unrelated
117 (void)@selector(inBase); // strict-warning{{@selector expression formed with potentially direct selector}}
118 (void)@selector(inBaseImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
119 (void)@selector(inBaseCat); // strict-warning{{@selector expression formed with potentially direct selector}}
120 (void)@selector(inBaseCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
121 (void)@selector(inDerived); // strict-warning{{@selector expression formed with potentially direct selector}}
122 (void)@selector(inDerivedImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
123 (void)@selector(inDerivedCat); // strict-warning{{@selector expression formed with potentially direct selector}}
124 (void)@selector(inDerivedCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
125 (void)@selector(inDerivedClass); // strict-warning{{@selector expression formed with potentially direct selector}}
126 (void)@selector(inBaseClass); // strict-warning{{@selector expression formed with potentially direct selector}}
127 (void)@selector(inDerivedCatClass); // strict-warning{{@selector expression formed with potentially direct selector}}
131 @implementation Dummies
135 -(void)inBaseCatImpl {}
137 -(void)inDerivedImpl {}
138 -(void)inDerivedCat {}
139 -(void)inDerivedCatImpl {}
140 +(void)inBaseClass {}
141 +(void)inDerivedClass {}
142 +(void)inDerivedCatClass {}
145 (void)@selector(inBase);
146 (void)@selector(inBaseImpl);
147 (void)@selector(inBaseCat);
148 (void)@selector(inBaseCatImpl);
149 (void)@selector(inDerived);
150 (void)@selector(inDerivedImpl);
151 (void)@selector(inDerivedCat);
152 (void)@selector(inDerivedCatImpl);
153 (void)@selector(inDerivedClass);
154 (void)@selector(inBaseClass);
155 (void)@selector(inDerivedCatClass);