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
This commit is contained in:
Marek Polacek 2015-09-14 10:36:50 +00:00 committed by Marek Polacek
parent 0f876f2288
commit aa256c4aed
7 changed files with 22 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2015-09-14 Marek Polacek <polacek@redhat.com>
* rtlanal.c (split_double): Cast to unsigned when shifting a negative
value.
* sched-int.h (UNKNOWN_DEP_COST): Likewise.
2015-09-11 Mark Wielaard <mjw@redhat.com>
PR c/28901

View File

@ -1,3 +1,8 @@
2015-09-14 Marek Polacek <polacek@redhat.com>
* c-common.c (warn_for_sign_compare): Cast to unsigned when shifting
a negative value.
2015-09-11 Mark Wielaard <mjw@redhat.com>
PR c/28901

View File

@ -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)

View File

@ -1,3 +1,8 @@
2015-09-14 Marek Polacek <polacek@redhat.com>
* c-typeck.c (set_nonincremental_init_from_string): Use
HOST_WIDE_INT_M1U when shifting a negative value.
2015-09-09 Mark Wielaard <mjw@redhat.com>
* c-typeck.c (build_binary_op): Check and warn when nonnull arg

View File

@ -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,

View File

@ -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

View File

@ -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;