Skip to content

Commit f4b0431

Browse files
authored
Merge pull request #11003 from swiftlang/feature-availability-protocol
[feature availability] Don't warn about unguarded uses of ObjC protocols adopted by interfaces
2 parents 432010a + c0734a7 commit f4b0431

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
@@ -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)