aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2019-10-11 08:57:48 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2019-10-11 08:57:48 +0000
commit807f01d1bbb6629ab6da9ac3052a3715ad5348cf (patch)
tree399374b11d28515dc0466b4c9da96cc80cf6beea
parentc0f89306e18742cd58fadf0898461fac3098f2c2 (diff)
* gcc-interface/decl.c (annotate_value) <INTEGER_CST>: Really test the
sign of the value when deciding to build a NEGATE_EXPR. <PLUS_EXPR>: Remove redundant line. <BIT_AND_EXPR>: Do the negation here. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@276868 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/gcc-interface/decl.c16
2 files changed, 14 insertions, 9 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 478bb86cf4f..c7e8185c67f 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2019-10-11 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/decl.c (annotate_value) <INTEGER_CST>: Really test the
+ sign of the value when deciding to build a NEGATE_EXPR.
+ <PLUS_EXPR>: Remove redundant line.
+ <BIT_AND_EXPR>: Do the negation here.
+
2019-09-23 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Attribute_to_gnu): Test Can_Use_Internal_Rep
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 9f499e0ad59..3e8552a2d5c 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -8107,9 +8107,8 @@ annotate_value (tree gnu_size)
{
case INTEGER_CST:
/* For negative values, build NEGATE_EXPR of the opposite. Such values
- can appear for discriminants in expressions for variants. Note that,
- sizetype being unsigned, we don't directly use tree_int_cst_sgn. */
- if (tree_int_cst_sign_bit (gnu_size))
+ can appear for discriminants in expressions for variants. */
+ if (tree_int_cst_sgn (gnu_size) < 0)
{
tree t = wide_int_to_tree (sizetype, -wi::to_wide (gnu_size));
tcode = Negate_Expr;
@@ -8187,9 +8186,8 @@ annotate_value (tree gnu_size)
&& tree_int_cst_sign_bit (TREE_OPERAND (gnu_size, 1)))
{
tcode = Minus_Expr;
- ops[0] = annotate_value (TREE_OPERAND (gnu_size, 0));
- wide_int op1 = -wi::to_wide (TREE_OPERAND (gnu_size, 1));
- ops[1] = annotate_value (wide_int_to_tree (sizetype, op1));
+ wide_int wop1 = -wi::to_wide (TREE_OPERAND (gnu_size, 1));
+ ops[1] = annotate_value (wide_int_to_tree (sizetype, wop1));
break;
}
@@ -8230,9 +8228,9 @@ annotate_value (tree gnu_size)
Such values can appear in expressions with aligning patterns. */
if (TREE_CODE (TREE_OPERAND (gnu_size, 1)) == INTEGER_CST)
{
- wide_int op1 = wi::sext (wi::to_wide (TREE_OPERAND (gnu_size, 1)),
- TYPE_PRECISION (sizetype));
- ops[1] = annotate_value (wide_int_to_tree (sizetype, op1));
+ wide_int wop1 = -wi::to_wide (TREE_OPERAND (gnu_size, 1));
+ tree op1 = wide_int_to_tree (sizetype, wop1);
+ ops[1] = annotate_value (build1 (NEGATE_EXPR, sizetype, op1));
}
break;