This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
silence -Wparentheses-equality
authorDavid Mitchell <davem@iabyn.com>
Mon, 28 Mar 2016 09:52:18 +0000 (10:52 +0100)
committerDavid Mitchell <davem@iabyn.com>
Mon, 28 Mar 2016 10:04:36 +0000 (11:04 +0100)
Clang has taken it upon itself to warn when an equality is wrapped in
double parentheses, e.g.

    ((foo == bar))

Which is a bit dumb, as any code along the lines of

    #define isBAR (foo == BAR)
    if (isBAR) {}

will trigger the warning.

This commit shuts clang up by putting in a harmless cast:

    #define isBAR cBOOL(foo == BAR)

cop.h
perl.h
regcomp.h
regen/warnings.pl
warnings.h

diff --git a/cop.h b/cop.h
index dfb4a00..1795dc3 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -1055,8 +1055,8 @@ typedef struct stackinfo PERL_SI;
        }                                                               \
     } STMT_END
 
        }                                                               \
     } STMT_END
 
-#define IN_PERL_COMPILETIME    (PL_curcop == &PL_compiling)
-#define IN_PERL_RUNTIME                (PL_curcop != &PL_compiling)
+#define IN_PERL_COMPILETIME    cBOOL(PL_curcop == &PL_compiling)
+#define IN_PERL_RUNTIME                cBOOL(PL_curcop != &PL_compiling)
 
 
 
 
 
 
diff --git a/perl.h b/perl.h
index 2ee79c4..0468a1c 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -5275,7 +5275,7 @@ EXTCONST char *const PL_phase_names[];
 /* Do not use this macro. It only exists for extensions that rely on PL_dirty
  * instead of using the newer PL_phase, which provides everything PL_dirty
  * provided, and more. */
 /* Do not use this macro. It only exists for extensions that rely on PL_dirty
  * instead of using the newer PL_phase, which provides everything PL_dirty
  * provided, and more. */
-#  define PL_dirty (PL_phase == PERL_PHASE_DESTRUCT)
+#  define PL_dirty cBOOL(PL_phase == PERL_PHASE_DESTRUCT)
 
 #  define PL_amagic_generation PL_na
 #endif /* !PERL_CORE */
 
 #  define PL_amagic_generation PL_na
 #endif /* !PERL_CORE */
index c2e44aa..a8842a1 100644 (file)
--- a/regcomp.h
+++ b/regcomp.h
@@ -368,7 +368,7 @@ struct regnode_ssc {
 
 #define REG_MAGIC 0234
 
 
 #define REG_MAGIC 0234
 
-#define SIZE_ONLY (RExC_emit == (regnode *) & RExC_emit_dummy)
+#define SIZE_ONLY cBOOL(RExC_emit == (regnode *) & RExC_emit_dummy)
 #define PASS1 SIZE_ONLY
 #define PASS2 (! SIZE_ONLY)
 
 #define PASS1 SIZE_ONLY
 #define PASS2 (! SIZE_ONLY)
 
index d81a078..22c9c15 100644 (file)
@@ -358,8 +358,8 @@ EOM
 
   print $warn <<'EOM';
 
 
   print $warn <<'EOM';
 
-#define isLEXWARN_on   (PL_curcop->cop_warnings != pWARN_STD)
-#define isLEXWARN_off  (PL_curcop->cop_warnings == pWARN_STD)
+#define isLEXWARN_on   cBOOL(PL_curcop->cop_warnings != pWARN_STD)
+#define isLEXWARN_off  cBOOL(PL_curcop->cop_warnings == pWARN_STD)
 #define isWARN_ONCE    (PL_dowarn & (G_WARN_ON|G_WARN_ONCE))
 #define isWARN_on(c,x) (IsSet((U8 *)(c + 1), 2*(x)))
 #define isWARNf_on(c,x)        (IsSet((U8 *)(c + 1), 2*(x)+1))
 #define isWARN_ONCE    (PL_dowarn & (G_WARN_ON|G_WARN_ONCE))
 #define isWARN_on(c,x) (IsSet((U8 *)(c + 1), 2*(x)))
 #define isWARNf_on(c,x)        (IsSet((U8 *)(c + 1), 2*(x)+1))
index 4ab2d1d..337bef3 100644 (file)
 #define WARN_ALLstring                  "\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125"
 #define WARN_NONEstring                         "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
 
 #define WARN_ALLstring                  "\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125\125"
 #define WARN_NONEstring                         "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
 
-#define isLEXWARN_on   (PL_curcop->cop_warnings != pWARN_STD)
-#define isLEXWARN_off  (PL_curcop->cop_warnings == pWARN_STD)
+#define isLEXWARN_on   cBOOL(PL_curcop->cop_warnings != pWARN_STD)
+#define isLEXWARN_off  cBOOL(PL_curcop->cop_warnings == pWARN_STD)
 #define isWARN_ONCE    (PL_dowarn & (G_WARN_ON|G_WARN_ONCE))
 #define isWARN_on(c,x) (IsSet((U8 *)(c + 1), 2*(x)))
 #define isWARNf_on(c,x)        (IsSet((U8 *)(c + 1), 2*(x)+1))
 #define isWARN_ONCE    (PL_dowarn & (G_WARN_ON|G_WARN_ONCE))
 #define isWARN_on(c,x) (IsSet((U8 *)(c + 1), 2*(x)))
 #define isWARNf_on(c,x)        (IsSet((U8 *)(c + 1), 2*(x)+1))