This is the mail archive of the
mailing list for the GCC project.
Re: [Patch, fortran] PR34438 - gfortran not compliant w.r.t default initialization of derived type component and implicit SAVE attribute
I only now had a chance to look at this. The problem is dumb stupidity
on my part:
Originally, we had
/* Initialize INTENT(OUT) derived type dummies. */
init_intent_out_dt (gfc_symbol * proc_sym, tree body)
- gfc_expr *tmpe;
- tree tmp;
- tree present;
for (f = proc_sym->formal; f; f = f->next)
! if (f->sym && f->sym->attr.intent == INTENT_OUT
! && f->sym->ts.type == BT_DERIVED
! && !f->sym->ts.derived->attr.alloc_comp
! && f->sym->value)
! gcc_assert (!f->sym->attr.allocatable);
! gfc_set_sym_referenced (f->sym);
! tmpe = gfc_lval_expr_from_sym (f->sym);
! tmp = gfc_trans_assignment (tmpe, f->sym->value, false);
! present = gfc_conv_expr_present (f->sym);
! tmp = build3 (COND_EXPR, TREE_TYPE (tmp), present,
! tmp, build_empty_stmt ());
! gfc_add_expr_to_block (&fnblock, tmp);
! gfc_free_expr (tmpe);
gfc_add_expr_to_block (&fnblock, body);
return gfc_finish_block (&fnblock);
Note the detection of the presence of the dummy, which I put in the
original. For some reason, I negelected to retain it, with the
inevitable consequence that the ENTRY where d1 is not present tries to
initialise a NULL.
I will add to the testcase and commit asap.
Sorry it's taken so long and thanks for the test.