Skip to content

Commit 556ab11

Browse files
committed
[feature availability] Don't warn about unguarded uses of ObjC protocols
adopted by interfaces We don't want to force users to annotate interfaces/protocols/categories adopting the annotated protocol with feature attributes. rdar://155690040
1 parent b14c2f0 commit 556ab11

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
376376
DiagnoseAvailabilityOfDecl(D, Locs, UnknownObjCClass, ObjCPropertyAccess,
377377
AvoidPartialAvailabilityChecks, ClassReceiver);
378378

379-
DiagnoseFeatureAvailabilityOfDecl(D, Locs);
379+
if (!AvoidPartialAvailabilityChecks)
380+
DiagnoseFeatureAvailabilityOfDecl(D, Locs);
380381

381382
DiagnoseUnusedOfDecl(*this, D, Loc);
382383

clang/test/SemaObjC/feature-availability.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ @interface Base3 <P1>
151151
@end
152152

153153
__attribute__((availability(domain:feature1, AVAIL)))
154-
@interface Base4 <P1> // expected-error {{use of 'P1' requires feature 'feature1' to be unavailable}}
154+
@interface Base4 <P1>
155155
@end
156156

157157
__attribute__((availability(domain:feature1, AVAIL)))
@@ -170,8 +170,10 @@ @interface Base5(Cat3) <P2>
170170
@end
171171

172172
__attribute__((availability(domain:feature1, UNAVAIL)))
173-
@interface Base5(Cat4) <P2> // expected-error {{use of 'P2' requires feature 'feature1' to be available}}
173+
@interface Base5(Cat4) <P2>
174174
@end
175175

176-
@interface Base6 <P1, P2> // expected-error {{use of 'P1' requires feature 'feature1' to be unavailable}} expected-error {{use of 'P2' requires feature 'feature1' to be available}}
176+
@interface Base6 <P1, P2>
177177
@end
178+
179+
void foo(id<P1>); // expected-error {{use of 'P1' requires feature 'feature1' to be unavailable}}

0 commit comments

Comments
 (0)