This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Silence wrong clang warnings
authorKarl Williamson <khw@cpan.org>
Mon, 26 Feb 2018 04:38:21 +0000 (21:38 -0700)
committerKarl Williamson <khw@cpan.org>
Fri, 2 Mar 2018 01:47:10 +0000 (18:47 -0700)
Clang thread-safety analysis fails to correctly work in this situation
(and is documented as failing), so turn off that warning here.

perl.h
sv.c

diff --git a/perl.h b/perl.h
index 1473721..d20fdd0 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -5590,6 +5590,7 @@ typedef struct am_table_short AMTS;
  * this would be an attempt to complement the LC_NUMERIC state, and we're not
  * supposed to because it's locked */
 #    define LC_NUMERIC_LOCK(cond_to_panic_if_already_locked)                \
+        CLANG_DIAG_IGNORE(-Wthread-safety)                                 \
         STMT_START {                                                        \
             if (PL_lc_numeric_mutex_depth <= 0) {                           \
                 MUTEX_LOCK(&PL_lc_numeric_mutex);                           \
@@ -5617,7 +5618,7 @@ typedef struct am_table_short AMTS;
                 MUTEX_UNLOCK(&PL_lc_numeric_mutex);                         \
                 PL_lc_numeric_mutex_depth = 0;                              \
                 DEBUG_Lv(PerlIO_printf(Perl_debug_log,                      \
-                         "%s: %d: unlocking lc_numeric; depth=0\n",           \
+                         "%s: %d: unlocking lc_numeric; depth=0\n",         \
                          __FILE__, __LINE__));                              \
             }                                                               \
             else {                                                          \
@@ -5626,7 +5627,8 @@ typedef struct am_table_short AMTS;
                         "%s: %d: avoided lc_numeric_unlock; depth=%d\n",    \
                         __FILE__, __LINE__, PL_lc_numeric_mutex_depth));    \
             }                                                               \
-        } STMT_END
+        } STMT_END                                                          \
+        CLANG_DIAG_RESTORE
 
 /* This is used as a generic lock for locale operations.  For example this is
  * used when calling nl_langinfo() so that another thread won't zap the
diff --git a/sv.c b/sv.c
index 2475d46..231215e 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -2667,6 +2667,7 @@ Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags)
     if (SvTYPE(sv) < SVt_NV) {
        /* The logic to use SVt_PVNV if necessary is in sv_upgrade.  */
        sv_upgrade(sv, SVt_NV);
+        CLANG_DIAG_IGNORE_STMT(-Wthread-safety);
        DEBUG_c({
             DECLARATION_FOR_LC_NUMERIC_MANIPULATION;
             STORE_LC_NUMERIC_SET_STANDARD();
@@ -2675,6 +2676,8 @@ Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags)
                          PTR2UV(sv), SvNVX(sv));
             RESTORE_LC_NUMERIC();
        });
+        CLANG_DIAG_RESTORE_STMT;
+
     }
     else if (SvTYPE(sv) < SVt_PVNV)
        sv_upgrade(sv, SVt_PVNV);
@@ -2809,6 +2812,7 @@ Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags)
           and ideally should be fixed.  */
        return 0.0;
     }
+    CLANG_DIAG_IGNORE_STMT(-Wthread-safety);
     DEBUG_c({
         DECLARATION_FOR_LC_NUMERIC_MANIPULATION;
         STORE_LC_NUMERIC_SET_STANDARD();
@@ -2816,6 +2820,7 @@ Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags)
                      PTR2UV(sv), SvNVX(sv));
         RESTORE_LC_NUMERIC();
     });
+    CLANG_DIAG_RESTORE_STMT;
     return SvNVX(sv);
 }