]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (annotate_value): Really test the sign of the value when deciding to build...
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 11 Oct 2019 08:57:58 +0000 (08:57 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 11 Oct 2019 08:57:58 +0000 (08:57 +0000)
* 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.

From-SVN: r276869

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c

index 5c39dbc632852f1a8e55c09d6df4ca497ef85962..176a5c4bc40ca50f3817487f3c88ec33b4eaf139 100644 (file)
@@ -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
index 3a5126ad3dad3c7915791227ca381dfff1b364fd..eb337152bcc9650f5d09877b3b2f1393adad0d11 100644 (file)
@@ -8073,9 +8073,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::neg (gnu_size));
          tcode = Negate_Expr;
@@ -8148,9 +8147,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::neg (TREE_OPERAND (gnu_size, 1));
-         ops[1] = annotate_value (wide_int_to_tree (sizetype, op1));
+         wide_int wop1 = wi::neg (TREE_OPERAND (gnu_size, 1));
+         ops[1] = annotate_value (wide_int_to_tree (sizetype, wop1));
          break;
        }
 
@@ -8189,9 +8187,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 (TREE_OPERAND (gnu_size, 1),
-                                  TYPE_PRECISION (sizetype));
-         ops[1] = annotate_value (wide_int_to_tree (sizetype, op1));
+         wide_int wop1 = wi::neg (TREE_OPERAND (gnu_size, 1));
+         tree op1 = wide_int_to_tree (sizetype, wop1);
+         ops[1] = annotate_value (build1 (NEGATE_EXPR, sizetype, op1));
        }
       break;