]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: double-int.c (div_and_round_double): Use the proper predicate to detect...
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 28 May 2014 16:46:07 +0000 (16:46 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 28 May 2014 16:46:07 +0000 (16:46 +0000)
Backport from mainline
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.

From-SVN: r211028

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

index e38b55364786aeac2de876aea4409b568eda6741..a6df5af7e15510022decffd935bf2148438601d8 100644 (file)
@@ -1,3 +1,11 @@
+2014-05-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       Backport from mainline
+       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-28  Georg-Johann Lay  <avr@gjlay.de>
 
        PR target/61044
index 918ce2273ecaca2952f250463c4750cd98fa5d2c..53a69ad67a71f297825817380a4b2a7d2f7e6e8a 100644 (file)
@@ -616,7 +616,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 55ea1088e24cb3bebe91bbba6c3eca67e43b83ae..da44bda52ffdb72c7d6f5b87cdf2f4b4d3b9acf0 100644 (file)
@@ -1,3 +1,10 @@
+2014-05-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       Backport from mainline
+       2014-05-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/overflow_fixed.adb: New test.
+
 2014-05-27  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/aliasing1.adb (dg-final): Robustify pattern matching.
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;