+2014-03-27 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/59604
+ PR fortran/58003
+ * gfortran.h (gfc_convert_mpz_to_signed): Add prototype.
+ * arith.c (gfc_int2int): Convert number to signed if
+ arithmetic overflow is not checked.
+ * simplify.c (convert_mpz_to_unsigned): Only trigger assert for
+ size if range checking is in force.
+ (convert_mpz_to_signed): Make non-static, rename to
+ (gfc_convert_mpz_to_signed).
+ (simplify_dshift): Use gfc_convert_mpz_to_signed.
+ (gfc_simplify_ibclr): Likewise.
+ (gfc_simplify_ibits): Likewise.
+ (gfc_simplify_ibset): Likewise.
+ (simplify_shift): Likewise.
+ (gfc_simplify_ishiftc): Likewise.
+ (gfc_simplify_maskr): Likewise.
+ (gfc_simplify_maskl): Likewise.
+
2014-04-22 Tobias Burnus <burnus@net-b.de>
PR fortran/60881
if (mpz_sgn (x) < 0)
{
- /* Confirm that no bits above the signed range are unset. */
- gcc_assert (mpz_scan0 (x, bitsize-1) == ULONG_MAX);
+ /* Confirm that no bits above the signed range are unset if we
+ are doing range checking. */
+ if (gfc_option.flag_range_check != 0)
+ gcc_assert (mpz_scan0 (x, bitsize-1) == ULONG_MAX);
mpz_init_set_ui (mask, 1);
mpz_mul_2exp (mask, mask, bitsize);
If the bitsize-1 bit is set, this is taken as a sign bit and
the number is converted to the corresponding negative number. */
-static void
-convert_mpz_to_signed (mpz_t x, int bitsize)
+void
+gfc_convert_mpz_to_signed (mpz_t x, int bitsize)
{
mpz_t mask;
- /* Confirm that no bits above the unsigned range are set. */
- gcc_assert (mpz_scan1 (x, bitsize) == ULONG_MAX);
+ /* Confirm that no bits above the unsigned range are set if we are
+ doing range checking. */
+ if (gfc_option.flag_range_check != 0)
+ gcc_assert (mpz_scan1 (x, bitsize) == ULONG_MAX);
if (mpz_tstbit (x, bitsize - 1) == 1)
{
mpz_setbit (result->value.integer, shift + i);
/* Convert to a signed value. */
- convert_mpz_to_signed (result->value.integer, size);
+ gfc_convert_mpz_to_signed (result->value.integer, size);
return result;
}
mpz_clrbit (result->value.integer, pos);
- convert_mpz_to_signed (result->value.integer,
+ gfc_convert_mpz_to_signed (result->value.integer,
gfc_integer_kinds[k].bit_size);
return result;
free (bits);
- convert_mpz_to_signed (result->value.integer,
+ gfc_convert_mpz_to_signed (result->value.integer,
gfc_integer_kinds[k].bit_size);
return result;
mpz_setbit (result->value.integer, pos);
- convert_mpz_to_signed (result->value.integer,
+ gfc_convert_mpz_to_signed (result->value.integer,
gfc_integer_kinds[k].bit_size);
return result;
}
}
- convert_mpz_to_signed (result->value.integer, bitsize);
+ gfc_convert_mpz_to_signed (result->value.integer, bitsize);
free (bits);
return result;
}
}
- convert_mpz_to_signed (result->value.integer, isize);
+ gfc_convert_mpz_to_signed (result->value.integer, isize);
free (bits);
return result;
mpz_mul_2exp (result->value.integer, result->value.integer, arg);
mpz_sub_ui (result->value.integer, result->value.integer, 1);
- convert_mpz_to_signed (result->value.integer, gfc_integer_kinds[k].bit_size);
+ gfc_convert_mpz_to_signed (result->value.integer, gfc_integer_kinds[k].bit_size);
return result;
}
mpz_sub (result->value.integer, z, result->value.integer);
mpz_clear (z);
- convert_mpz_to_signed (result->value.integer, gfc_integer_kinds[k].bit_size);
+ gfc_convert_mpz_to_signed (result->value.integer, gfc_integer_kinds[k].bit_size);
return result;
}