]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
double-int.c (div_and_round_double): Use the proper predicate to detect a negative...
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 27 May 2014 20:30:18 +0000 (20:30 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 27 May 2014 20:30:18 +0000 (20:30 +0000)
* double-int.c (div_and_round_double) <ROUND_DIV_EXPR>: Use the proper
predicate to detect a negative quotient.

From-SVN: r210981

gcc/ChangeLog
gcc/double-int.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/overflow_fixed.adb [new file with mode: 0644]

index 9b8621e767b64f539aa6319d69b356155368a710..8898e8de95f410feea64a591f04ac9a8b92da6da 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * double-int.c (div_and_round_double) <ROUND_DIV_EXPR>: Use the proper
+       predicate to detect a negative quotient.
+
 2014-05-27  Eric Botcazou  <ebotcazou@adacore.com>
 
        * fold-const.c (fold_comparison): Clean up and extend X +- C1 CMP C2
index 454655d9049738b142b2d6249877bd016e656ede..f6e340bebfe6f238206fd5005037a467573b245d 100644 (file)
@@ -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);
index cb8577a35609f712388961d68c0864313626eb7b..d24b31eae609781570bf3e203488d7a021d78fcf 100644 (file)
@@ -1,3 +1,7 @@
+2014-05-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/overflow_fixed.adb: New test.
+
 2014-05-27  Marek Polacek  <polacek@redhat.com>
 
        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 (file)
index 0000000..6ece515
--- /dev/null
@@ -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;