Commit 66c9b3f5 by Eric Botcazou Committed by Eric Botcazou

utils.c (convert): When converting to a padding type...

	* gcc-interface/utils.c (convert): When converting to a padding type,
	reuse an existing CONSTRUCTOR if it has got the right size.

From-SVN: r251924
parent a49bf6f0
2017-09-09 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/utils.c (convert): When converting to a padding type,
reuse an existing CONSTRUCTOR if it has got the right size.
2017-09-08 Nicolas Roche <roche@adacore.com>
* gcc-interface/Make-lang.in, gcc-interface/Makefile.in: Find runtime
......
......@@ -4219,8 +4219,6 @@ convert (tree type, tree expr)
constructor to build the record, unless a variable size is involved. */
else if (code == RECORD_TYPE && TYPE_PADDING_P (type))
{
vec<constructor_elt, va_gc> *v;
/* If we previously converted from another type and our type is
of variable size, remove the conversion to avoid the need for
variable-sized temporaries. Likewise for a conversion between
......@@ -4272,9 +4270,21 @@ convert (tree type, tree expr)
expr),
false);
tree t = convert (TREE_TYPE (TYPE_FIELDS (type)), expr);
/* If converting to the inner type has already created a CONSTRUCTOR with
the right size, then reuse it instead of creating another one. This
can happen for the padding type built to overalign local variables. */
if (TREE_CODE (t) == VIEW_CONVERT_EXPR
&& TREE_CODE (TREE_OPERAND (t, 0)) == CONSTRUCTOR
&& TREE_CONSTANT (TYPE_SIZE (TREE_TYPE (TREE_OPERAND (t, 0))))
&& tree_int_cst_equal (TYPE_SIZE (type),
TYPE_SIZE (TREE_TYPE (TREE_OPERAND (t, 0)))))
return build1 (VIEW_CONVERT_EXPR, type, TREE_OPERAND (t, 0));
vec<constructor_elt, va_gc> *v;
vec_alloc (v, 1);
CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (type),
convert (TREE_TYPE (TYPE_FIELDS (type)), expr));
CONSTRUCTOR_APPEND_ELT (v, TYPE_FIELDS (type), t);
return gnat_build_constructor (type, v);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment