http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55978
--- Comment #17 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-02-06
11:16:38 UTC ---
(In reply to comment #16)
> For the allocatable case, no packing is done at all (I guess it's just not
> needed there, since an allocatable array, contrary to a pointer, is always
> contiguous, right?).
Good point. Also simply contiguous pointers shouldn't need packing, though, I
think that is checked before - hence, this code only reaches
non-simply-contiguous arrays.
Additionally, I think we currently add the wrong checks for (sym = DT with
pointer, optional attribute; fsym = optional):
7159 if (fsym && fsym->attr.optional && sym && sym->attr.optional)
7160 {
7161 tmp = gfc_conv_expr_present (sym);
When one uses"sym%comp" as actual argument. In that case "sym" has to be
present and a non-null pointer. Thus, if "comp" is a pointer, only "sym%comp ==
NULL" needs to be checked, if "comp" isn't a pointer, no check at all is
required.
Maybe one should rename "gfc_conv_expr_present" to "gfc_conv_sym_present" - and
add a version for expressions, which can then be called for:
if (fsym && fsym->attr.optional
&& (sym && sym->attr.optional)
|| expr->expr_type == EXPR_NULL
|| (expr->ts.type != BT_CLASS gfc_expr_attr(expr).pointer)
|| (expr->ts.type == BT_CLASS gfc_expr_attr(expr).class_pointer)))
{
tmp = gfc_conv_expr_present (sym);