This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Move GCC DIAG IGNORE
authorKarl Williamson <khw@cpan.org>
Tue, 26 Dec 2023 13:09:49 +0000 (06:09 -0700)
committerKarl Williamson <khw@cpan.org>
Mon, 8 Jan 2024 22:41:59 +0000 (15:41 -0700)
The previous commit changed two nested switch() statements.  The inner
one turned off implicit switch() case statement fallthrough warnings.
This commit applies that to the entire outer switch().

locale.c

index e095ae7..5b8e6f8 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -6179,6 +6179,8 @@ S_emulate_langinfo(pTHX_ const nl_item item,
 
 #    endif
 
+    GCC_DIAG_IGNORE_STMT(-Wimplicit-fallthrough);
+
     switch (item) {
 
 #    ifdef HAS_LOCALECONV
@@ -6489,8 +6491,6 @@ S_emulate_langinfo(pTHX_ const nl_item item,
 
 #    endif
 
-            GCC_DIAG_IGNORE_STMT(-Wimplicit-fallthrough);
-
         /* Nested switch for LC_TIME items, plus the default: case is for
          * unknown items */
         switch (item) {
@@ -6574,8 +6574,6 @@ S_emulate_langinfo(pTHX_ const nl_item item,
 
             } /* End of inner switch() */
 
-            GCC_DIAG_RESTORE_STMT;
-
             if (! format) {
                 retval = "";
                 break;
@@ -6661,6 +6659,8 @@ S_emulate_langinfo(pTHX_ const nl_item item,
        }    /* End of braced group for outer switch 'default:' case */
     } /* Giant switch() of nl_langinfo() items */
 
+    GCC_DIAG_RESTORE_STMT;
+
     if (utf8ness) {
         *utf8ness = is_utf8;
     }