Skip to content

Commit c0734a7

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 1d83024 commit c0734a7

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
@@ -369,7 +369,8 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
369369
DiagnoseAvailabilityOfDecl(D, Locs, UnknownObjCClass, ObjCPropertyAccess,
370370
AvoidPartialAvailabilityChecks, ClassReceiver);
371371

372-
DiagnoseFeatureAvailabilityOfDecl(D, Locs);
372+
if (!AvoidPartialAvailabilityChecks)
373+
DiagnoseFeatureAvailabilityOfDecl(D, Locs);
373374

374375
DiagnoseUnusedOfDecl(*this, D, Loc);
375376

clang/test/SemaObjC/feature-availability.m

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

149149
__attribute__((availability(domain:feature1, AVAIL)))
150-
@interface Base4 <P1> // expected-error {{use of 'P1' requires feature 'feature1' to be unavailable}}
150+
@interface Base4 <P1>
151151
@end
152152

153153
__attribute__((availability(domain:feature1, AVAIL)))
@@ -166,8 +166,10 @@ @interface Base5(Cat3) <P2>
166166
@end
167167

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

172-
@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}}
172+
@interface Base6 <P1, P2>
173173
@end
174+
175+
void foo(id<P1>); // expected-error {{use of 'P1' requires feature 'feature1' to be unavailable}}

0 commit comments

Comments
 (0)