From: Eric Botcazou Date: Sun, 13 Nov 2016 18:20:25 +0000 (+0000) Subject: decl.c (annotate_value): Deal specially with negative constants. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c0c54de6a09b8b280f2b3091f0e2c0894eb6f9d8;p=gcc.git decl.c (annotate_value): Deal specially with negative constants. * gcc-interface/decl.c (annotate_value) : Deal specially with negative constants. From-SVN: r242360 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f896d14820f..b3ac97c67c8 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2016-11-13 Eric Botcazou + + * gcc-interface/decl.c (annotate_value) : Deal specially + with negative constants. + 2016-11-13 Eric Botcazou * gcc-interface/utils2.c (gnat_protect_expr): Also protect only the diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 3aaaaca73ed..b6fce3ecf35 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: