File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,11 @@ class DiagnoseUnguardedFeatureAvailability
6767
6868 bool TraverseIfStmt (IfStmt *If);
6969
70+ // Ignore unguarded uses of enumerators inside case label expressions.
71+ bool TraverseCaseStmt (CaseStmt *Case) {
72+ return TraverseStmt (Case->getSubStmt ());
73+ }
74+
7075 bool VisitDeclRefExpr (DeclRefExpr *DRE) {
7176 diagnoseDeclFeatureAvailability (DRE->getDecl (), DRE->getBeginLoc ());
7277 return true ;
Original file line number Diff line number Diff line change @@ -235,6 +235,17 @@ void test7(void) {
235235 enum E e ;
236236 e = EA ;
237237 e = EB ; // expected-error {{cannot use 'EB' because feature 'feature2' is unavailable in this context}}
238+
239+ switch (e ) {
240+ case EA : {
241+ if (__builtin_available (domain :feature2 ))
242+ e = EB ;
243+ break ;
244+ }
245+ case EB : // no diagnostic
246+ e = EB ; // expected-error {{cannot use 'EB' because feature 'feature2' is unavailable in this context}}
247+ break ;
248+ }
238249 }
239250
240251 if (__builtin_available (domain :feature2 )) {
You can’t perform that action at this time.
0 commit comments