[PATCH] D36777: [Sema] Don't emit -Wunguarded-availability for switch cases
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 18 13:21:57 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311191: [Sema] Don't emit -Wunguarded-availability for switch cases (authored by epilk).
Changed prior to commit:
https://reviews.llvm.org/D36777?vs=111528&id=111727#toc
Repository:
rL LLVM
https://reviews.llvm.org/D36777
Files:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaObjC/unguarded-availability.m
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -7513,6 +7513,10 @@
bool TraverseLambdaExpr(LambdaExpr *E) { return true; }
+ // for 'case X:' statements, don't bother looking at the 'X'; it can't lead
+ // to any useful diagnostics.
+ bool TraverseCaseStmt(CaseStmt *CS) { return TraverseStmt(CS->getSubStmt()); }
+
bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *PRE) {
if (PRE->isClassReceiver())
DiagnoseDeclAvailability(PRE->getClassReceiver(), PRE->getReceiverLocation());
Index: cfe/trunk/test/SemaObjC/unguarded-availability.m
===================================================================
--- cfe/trunk/test/SemaObjC/unguarded-availability.m
+++ cfe/trunk/test/SemaObjC/unguarded-availability.m
@@ -287,3 +287,27 @@
@interface BaseClass (CategoryWithNewProtocolRequirement) <NewProtocol>
@end
+
+typedef enum {
+ AK_Dodo __attribute__((availability(macos, deprecated=10.3))), // expected-note 3 {{marked deprecated here}}
+ AK_Cat __attribute__((availability(macos, introduced=10.4))),
+ AK_CyborgCat __attribute__((availability(macos, introduced=10.12))), // expected-note {{marked partial here}}
+} Animals;
+
+void switchAnimals(Animals a) {
+ switch (a) {
+ case AK_Dodo: break; // expected-warning{{'AK_Dodo' is deprecated}}
+ case AK_Cat: break;
+ case AK_Cat|AK_CyborgCat: break; // expected-warning{{case value not in enum}}
+ case AK_CyborgCat: break; // no warn
+ }
+
+ switch (a) {
+ case AK_Dodo...AK_CyborgCat: // expected-warning {{'AK_Dodo' is depr}}
+ break;
+ }
+
+ (void)AK_Dodo; // expected-warning{{'AK_Dodo' is deprecated}}
+ (void)AK_Cat; // no warning
+ (void)AK_CyborgCat; // expected-warning{{'AK_CyborgCat' is only available on macOS 10.12 or newer}} expected-note {{@available}}
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36777.111727.patch
Type: text/x-patch
Size: 1919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170818/e911b03a/attachment.bin>
More information about the cfe-commits
mailing list