diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2019-10-11 08:57:18 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2019-10-11 08:57:18 +0000 |
commit | 05626b02e8d02720771d361677b1d6cc38df9ddc (patch) | |
tree | 94c3f94377f4d1e8177698edacad64458991477e /gcc/ada | |
parent | 43b60e578393cc58f1d75387b811cc90bc74297b (diff) | |
download | gcc-05626b02e8d02720771d361677b1d6cc38df9ddc.zip gcc-05626b02e8d02720771d361677b1d6cc38df9ddc.tar.gz gcc-05626b02e8d02720771d361677b1d6cc38df9ddc.tar.bz2 |
decl.c (annotate_value): Really test the sign of the value when deciding to build a NEGATE_EXPR.
* 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: r276866
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 16 |
2 files changed, 14 insertions, 9 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 8e11108..792db56 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,12 @@ 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-10-11 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/decl.c (Gigi_Equivalent_Type) <E_Array_Subtype>: New case. Return the base type if the subtype is not constrained. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 2529824..2c5f573 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -8287,9 +8287,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; @@ -8367,9 +8366,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; } @@ -8410,9 +8408,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; |