diff mbox

[libgfortran] : Avoid left shift of negative value warning

Message ID CAFULd4bEvd9s4DUugbUG6t0Eraje+EJ+oMMuYKSz7nCREu+vZg@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak July 29, 2015, 11:57 a.m. UTC
Attached patch rewrites GFC_DTYPE_SIZE_MASK definition to avoid "left
shift of negative value" warning. during ligfortran build.

2015-07-29  Uros Bizjak  <ubizjak@gmail.com>

    PR libgfortran/66650
    * libgfortran.h (GFC_DTYPE_SIZE_MASK): Rewrite to avoid
    "left shift of negative value" warning.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

OK for mainline and release branches?

Uros.

---

Comments

FX Coudert July 29, 2015, 3:30 p.m. UTC | #1
> 2015-07-29  Uros Bizjak  <ubizjak@gmail.com>
> 
>    PR libgfortran/66650
>    * libgfortran.h (GFC_DTYPE_SIZE_MASK): Rewrite to avoid
>    "left shift of negative value" warning.

OK. Thanks for the patch.

FX
diff mbox

Patch

Index: libgfortran.h
===================================================================
--- libgfortran.h       (revision 226339)
+++ libgfortran.h       (working copy)
@@ -404,8 +404,7 @@ 

/* Macros to get both the size and the type with a single masking operation  */

-#define GFC_DTYPE_SIZE_MASK \
-  ((~((index_type) 0) >> GFC_DTYPE_SIZE_SHIFT) << GFC_DTYPE_SIZE_SHIFT)
+#define GFC_DTYPE_SIZE_MASK (-((index_type) 1 << GFC_DTYPE_SIZE_SHIFT))
#define GFC_DTYPE_TYPE_SIZE_MASK (GFC_DTYPE_SIZE_MASK | GFC_DTYPE_TYPE_MASK)

#define GFC_DTYPE_TYPE_SIZE(desc) ((desc)->dtype & GFC_DTYPE_TYPE_SIZE_MASK)