aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2017-09-05 09:12:07 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2017-09-05 09:12:07 +0000
commit1f073c9270d23a01f59b6871f127d99d54bd6670 (patch)
tree4da34380a93f050079a4205f3a11b72d696fe88a /gcc/ada/gcc-interface/utils.c
parent7ed9919dff52443091071203bf93685cf78002a3 (diff)
downloadgcc-1f073c9270d23a01f59b6871f127d99d54bd6670.zip
gcc-1f073c9270d23a01f59b6871f127d99d54bd6670.tar.gz
gcc-1f073c9270d23a01f59b6871f127d99d54bd6670.tar.bz2
utils.c (unchecked_convert): When the result type is a non-biased integral type with size 0...
* gcc-interface/utils.c (unchecked_convert): When the result type is a non-biased integral type with size 0, set the result to 0 directly. From-SVN: r251701
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r--gcc/ada/gcc-interface/utils.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index b0f6d2d..1c83a08 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -5257,20 +5257,26 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
? TYPE_RM_SIZE (etype)
: TYPE_SIZE (etype)) == 0)))
{
- tree base_type
- = gnat_type_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
- type_unsigned_for_rm (type));
- tree shift_expr
- = convert (base_type,
- size_binop (MINUS_EXPR,
- TYPE_SIZE (type), TYPE_RM_SIZE (type)));
- expr
- = convert (type,
- build_binary_op (RSHIFT_EXPR, base_type,
- build_binary_op (LSHIFT_EXPR, base_type,
- convert (base_type, expr),
- shift_expr),
- shift_expr));
+ if (integer_zerop (TYPE_RM_SIZE (type)))
+ expr = build_int_cst (type, 0);
+ else
+ {
+ tree base_type
+ = gnat_type_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
+ type_unsigned_for_rm (type));
+ tree shift_expr
+ = convert (base_type,
+ size_binop (MINUS_EXPR,
+ TYPE_SIZE (type), TYPE_RM_SIZE (type)));
+ expr
+ = convert (type,
+ build_binary_op (RSHIFT_EXPR, base_type,
+ build_binary_op (LSHIFT_EXPR, base_type,
+ convert (base_type,
+ expr),
+ shift_expr),
+ shift_expr));
+ }
}
/* An unchecked conversion should never raise Constraint_Error. The code