From 1f073c9270d23a01f59b6871f127d99d54bd6670 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Tue, 5 Sep 2017 09:12:07 +0000 Subject: 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 --- gcc/ada/gcc-interface/utils.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'gcc/ada/gcc-interface/utils.c') 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 -- cgit v1.1