From: Marek Polacek Date: Mon, 14 Sep 2015 10:36:50 +0000 (+0000) Subject: c-common.c (warn_for_sign_compare): Cast to unsigned when shifting a negative value. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aa256c4aedce567eff0d5fdf7b2e4067bc9e3c42;p=gcc.git c-common.c (warn_for_sign_compare): Cast to unsigned when shifting a negative value. * c-common.c (warn_for_sign_compare): Cast to unsigned when shifting a negative value. * c-typeck.c (set_nonincremental_init_from_string): Use HOST_WIDE_INT_M1U when shifting a negative value. * rtlanal.c (split_double): Cast to unsigned when shifting a negative value. * sched-int.h (UNKNOWN_DEP_COST): Likewise. From-SVN: r227743 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0aa46d05150..462a9977071 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-09-14 Marek Polacek + + * rtlanal.c (split_double): Cast to unsigned when shifting a negative + value. + * sched-int.h (UNKNOWN_DEP_COST): Likewise. + 2015-09-11 Mark Wielaard PR c/28901 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 0163b1593dd..8f8de188005 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2015-09-14 Marek Polacek + + * c-common.c (warn_for_sign_compare): Cast to unsigned when shifting + a negative value. + 2015-09-11 Mark Wielaard PR c/28901 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 9758b9e07e8..4b922bfbce1 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -12142,7 +12142,7 @@ warn_for_sign_compare (location_t location, if (bits < TYPE_PRECISION (result_type) && bits < HOST_BITS_PER_LONG && unsignedp) { - mask = (~ (HOST_WIDE_INT) 0) << bits; + mask = (~ (unsigned HOST_WIDE_INT) 0) << bits; if ((mask & constant) != mask) { if (constant == 0) diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 325686a4b1c..28914247424 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2015-09-14 Marek Polacek + + * c-typeck.c (set_nonincremental_init_from_string): Use + HOST_WIDE_INT_M1U when shifting a negative value. + 2015-09-09 Mark Wielaard * c-typeck.c (build_binary_op): Check and warn when nonnull arg diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 4108f27ab7c..3b2623140e3 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -8276,7 +8276,7 @@ set_nonincremental_init_from_string (tree str, { if (val[0] & (((HOST_WIDE_INT) 1) << (bitpos - 1))) { - val[0] |= ((HOST_WIDE_INT) -1) << bitpos; + val[0] |= HOST_WIDE_INT_M1U << bitpos; val[1] = -1; } } @@ -8287,8 +8287,7 @@ set_nonincremental_init_from_string (tree str, } else if (val[1] & (((HOST_WIDE_INT) 1) << (bitpos - 1 - HOST_BITS_PER_WIDE_INT))) - val[1] |= ((HOST_WIDE_INT) -1) - << (bitpos - HOST_BITS_PER_WIDE_INT); + val[1] |= HOST_WIDE_INT_M1U << (bitpos - HOST_BITS_PER_WIDE_INT); } value = wide_int_to_tree (type, diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index ef98f4bfb5c..b1be4db0dc1 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -5805,9 +5805,9 @@ split_double (rtx value, rtx *first, rtx *second) if (BITS_PER_WORD < HOST_BITS_PER_LONG && BITS_PER_WORD == 32) { if (l[0] & ((long) 1 << 31)) - l[0] |= ((long) (-1) << 32); + l[0] |= ((unsigned long) (-1) << 32); if (l[1] & ((long) 1 << 31)) - l[1] |= ((long) (-1) << 32); + l[1] |= ((unsigned long) (-1) << 32); } #endif diff --git a/gcc/sched-int.h b/gcc/sched-int.h index 61825ce5689..800262c4a4a 100644 --- a/gcc/sched-int.h +++ b/gcc/sched-int.h @@ -240,7 +240,7 @@ struct _dep int cost:20; }; -#define UNKNOWN_DEP_COST (-1<<19) +#define UNKNOWN_DEP_COST ((int) ((unsigned int) -1 << 19)) typedef struct _dep dep_def; typedef dep_def *dep_t;