This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: namelist array objects in subprograms


Anything that needs to handle array values expressons must do so explicitly.
See gfc_conv_intrinsic_transfer and gfc_conv_function_call for examples.

I took a long look at these functions and found that they only partially applicable because the call to get_new_var_expr does not fill the expr->ref, so preventing the tree walk. Of course, as in these two functions, the array dummy argument, added to a namelist, has to be an indirect reference.


Since all that is available in the transfer of the namelist elements is the gfc_symbol, so the need for an indirect reference can be detected using (sym->attr.dummy && sym->as->rank). Thus in trans-io.c:

for (nml = dt->namelist->namelist; nml; nml = nml->next)
 {
   gfc_init_se (&se, NULL);
   gfc_init_se (&se2, NULL);
   nmlvar = get_new_var_expr (nml->sym);
   nmlname = gfc_new_nml_name_expr (nml->sym->name);
   gfc_conv_expr_reference (&se2, nmlname);
   gfc_conv_expr_reference (&se, nmlvar);
   gfc_evaluate_now (se.expr, &se.pre);

if ( nml->sym->attr.dummy && nml->sym->as && nml->sym->as->rank)
se.expr = gfc_build_indirect_ref (se.expr); /* Here it is! */


transfer_namelist_element (&block, &nml->sym->ts, nml->sym->as, se.expr,
se2.expr, se2.string_length, nml->sym->name);
}


It works correctly, does not cause any regressions but is it acceptable? Presumably there are clever things that can be done with the backend decalaration?

Paul T



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]