c++: Layout decls with newly-complete type.

Martin's -Wplacement-new patch ran into a problem with DECL_SIZE not being
set on an extern variable for which the type was not complete until after
its declaration.  complete_vars was deliberately not calling layout_decl for
some reason, instead leaving that for expand_expr_real_1 much later in the
compilation.  But if we layout decls at declaration time, I don't see any
reason we shouldn't lay them out here, when their type is newly complete.

gcc/cp/ChangeLog:

	* decl.c (complete_vars): Call layout_var_decl.
This commit is contained in:
Jason Merrill 2020-09-04 12:14:19 -04:00
parent 2aad20c094
commit f627125855

View file

@ -17460,10 +17460,10 @@ complete_vars (tree type)
&& (TYPE_MAIN_VARIANT (strip_array_types (type))
== iv->incomplete_type))
{
/* Complete the type of the variable. The VAR_DECL itself
will be laid out in expand_expr. */
/* Complete the type of the variable. */
complete_type (type);
cp_apply_type_quals_to_decl (cp_type_quals (type), var);
layout_var_decl (var);
}
/* Remove this entry from the list. */