aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2014-05-27 20:30:18 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2014-05-27 20:30:18 +0000
commit5e67547dd5464761a3ed35c6e59fa231c8197740 (patch)
treeca1325b4034c2c31499a10629a5a4f4c371b6f4d
parent5c1bc275f4f85f2483fb2433b1592deeba1e3d6f (diff)
downloadgcc-5e67547dd5464761a3ed35c6e59fa231c8197740.zip
gcc-5e67547dd5464761a3ed35c6e59fa231c8197740.tar.gz
gcc-5e67547dd5464761a3ed35c6e59fa231c8197740.tar.bz2
double-int.c (div_and_round_double): Use the proper predicate to detect a negative quotient.
* double-int.c (div_and_round_double) <ROUND_DIV_EXPR>: Use the proper predicate to detect a negative quotient. From-SVN: r210981
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/double-int.c2
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/overflow_fixed.adb19
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9b8621e..8898e8d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
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
to X CMP C2 -+ C1 transformation to EQ_EXPR/NE_EXPR.
Add X - Y CMP 0 to X CMP Y transformation.
diff --git a/gcc/double-int.c b/gcc/double-int.c
index 454655d..f6e340b 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 cb8577a..d24b31e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..6ece515
--- /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;