From: Eric Botcazou Date: Fri, 19 Jun 2015 20:10:50 +0000 (+0000) Subject: decl.c (gnat_to_gnu_entity): Make sure the size of a padding type built around the... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b24f7345365c9faea98acfb1e145f3efe943f8d1;p=gcc.git decl.c (gnat_to_gnu_entity): Make sure the size of a padding type built around the return type is positive. * gcc-interface/decl.c (gnat_to_gnu_entity) : Make sure the size of a padding type built around the return type is positive. * gcc-interface/trans.c (gnat_to_gnu) : Use INIT_EXPR instead of MODIFY_EXPR to assign to the return object. From-SVN: r224697 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 47aaea51e4f..639d5c8c81e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2015-06-19 Eric Botcazou + + * gcc-interface/decl.c (gnat_to_gnu_entity) : Make sure + the size of a padding type built around the return type is positive. + * gcc-interface/trans.c (gnat_to_gnu) : + Use INIT_EXPR instead of MODIFY_EXPR to assign to the return object. + 2015-06-17 Andrew MacLeod * gcc-interface/cuintp.c: Do not include input.h, line-map.h or is-a.h. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index a17eab6dbfb..f487e9b5849 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -4242,12 +4242,23 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_return_type))) { tree orig_type = gnu_return_type; + tree max_return_size + = max_size (TYPE_SIZE (gnu_return_type), true); + + /* If the size overflows to 0, set it to an arbitrary positive + value so that assignments in the type are preserved. Their + actual size is independent of this positive value. */ + if (TREE_CODE (max_return_size) == INTEGER_CST + && TREE_OVERFLOW (max_return_size) + && integer_zerop (max_return_size)) + { + max_return_size = copy_node (bitsize_unit_node); + TREE_OVERFLOW (max_return_size) = 1; + } gnu_return_type - = maybe_pad_type (gnu_return_type, - max_size (TYPE_SIZE (gnu_return_type), - true), - 0, gnat_entity, false, false, definition, + = maybe_pad_type (gnu_return_type, max_return_size, 0, + gnat_entity, false, false, definition, true); /* Declare it now since it will never be declared otherwise. diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 85a77ea5faf..418f923b2bf 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -6861,7 +6861,7 @@ gnat_to_gnu (Node_Id gnat_node) tree gnu_ret_deref = build_unary_op (INDIRECT_REF, TREE_TYPE (gnu_ret_val), gnu_ret_obj); - gnu_result = build2 (MODIFY_EXPR, void_type_node, + gnu_result = build2 (INIT_EXPR, void_type_node, gnu_ret_deref, gnu_ret_val); add_stmt_with_node (gnu_result, gnat_node); gnu_ret_val = NULL_TREE;