aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2016-11-13 18:20:25 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2016-11-13 18:20:25 +0000
commitc0c54de6a09b8b280f2b3091f0e2c0894eb6f9d8 (patch)
treeb54385029fbc200a70eed0721cc800d5ee426c1d
parent96826e28ef9a627b82f1d7ccda0906f20dfe96d5 (diff)
downloadgcc-c0c54de6a09b8b280f2b3091f0e2c0894eb6f9d8.zip
gcc-c0c54de6a09b8b280f2b3091f0e2c0894eb6f9d8.tar.gz
gcc-c0c54de6a09b8b280f2b3091f0e2c0894eb6f9d8.tar.bz2
decl.c (annotate_value): Deal specially with negative constants.
* gcc-interface/decl.c (annotate_value) <INTEGER_CST>: Deal specially with negative constants. From-SVN: r242360
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/decl.c8
2 files changed, 13 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index f896d14..b3ac97c 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2016-11-13 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/decl.c (annotate_value) <INTEGER_CST>: Deal specially
+ with negative constants.
+
+2016-11-13 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/utils2.c (gnat_protect_expr): Also protect only the
address if the expression is the component of a dereference.
Do not use a reference type for the final temporary reference.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 3aaaaca..b6fce3e 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -8022,6 +8022,14 @@ annotate_value (tree gnu_size)
switch (TREE_CODE (gnu_size))
{
case INTEGER_CST:
+ /* For negative values, build NEGATE_EXPR of the opposite. Such values
+ 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));
+ return annotate_value (build1 (NEGATE_EXPR, sizetype, t));
+ }
+
return TREE_OVERFLOW (gnu_size) ? No_Uint : UI_From_gnu (gnu_size);
case COMPONENT_REF: