diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9b8621e767b..8898e8de95f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-05-27 Eric Botcazou + + * double-int.c (div_and_round_double) : Use the proper + predicate to detect a negative quotient. + 2014-05-27 Eric Botcazou * fold-const.c (fold_comparison): Clean up and extend X +- C1 CMP C2 diff --git a/gcc/double-int.c b/gcc/double-int.c index 454655d9049..f6e340bebfe 100644 --- a/gcc/double-int.c +++ b/gcc/double-int.c @@ -588,7 +588,7 @@ div_and_round_double (unsigned code, int uns, == (unsigned HOST_WIDE_INT) htwice) && (labs_den <= ltwice))) { - if (*hquo < 0) + if (quo_neg) /* quo = quo - 1; */ add_double (*lquo, *hquo, (HOST_WIDE_INT) -1, (HOST_WIDE_INT) -1, lquo, hquo); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cb8577a3560..d24b31eae60 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-05-27 Eric Botcazou + + * gnat.dg/overflow_fixed.adb: New test. + 2014-05-27 Marek Polacek PR c/56724 diff --git a/gcc/testsuite/gnat.dg/overflow_fixed.adb b/gcc/testsuite/gnat.dg/overflow_fixed.adb new file mode 100644 index 00000000000..6ece5152333 --- /dev/null +++ b/gcc/testsuite/gnat.dg/overflow_fixed.adb @@ -0,0 +1,19 @@ +-- { dg-do run } +-- { dg-options "-gnato -O" } + +procedure Overflow_Fixed is + + type Unsigned_8_Bit is mod 2**8; + + procedure Fixed_To_Eight (Value : Duration) is + Item : Unsigned_8_Bit; + begin + Item := Unsigned_8_Bit(Value); + raise Program_Error; + exception + when Constraint_Error => null; -- expected case + end; + +begin + Fixed_To_Eight (-0.5); +end;