[gfortran/patch] Support NAMELIST I/O of derived type variables (compiler side)

Victor Leikehman lei@haifasphere.co.il
Sun Aug 15 08:45:00 GMT 2004


Paul Brook wrote:

> Maybe transfer_namelist, which is consistent with the existing transfer_expr.

Maybe transfer_namelist_element is even better. But feel free to change it.

> Don't take the address if c->pointer is set.
Okay.

> Pass an extra string length parameter to st_set_nml_val_char for the string 
> length.
Okay.  This reqired one more change to the library, so be sure to pick up
the latest library patch.

>> 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);
>
> Add gfc_evaluate_now(se->expr, &se->pre); here.

I still don't understand.  The documentation of gfc_evaluate_now says:

/* If the an expression is not constant, evaluate it now.  We assign the
   result of the expression to an artificially created variable VAR, and
   return a pointer to the VAR_DECL node for this variable.  */

Since se.expr is an ADDR_EXPR pointing to VAR_DECL node anyway, why do
we need one more?  And if we do, why only se and not se2 ?
Applied your fix anyway :-)

Thanks,
	Victor

2004-08-15  Victor Leikehman  <lei@il.ibm.com>

	* trans-io.c (transfer_namelist_element): New. Recursively handle
	derived-type variables, in addition to the scalars.  For strings, pass
	their length. (build_dt): Code moved to build_namelist, with some
	changes and additions. (gfc_build_io_library_fndecls): Declare the fifth
	argument in st_set_nml_var_char -- string_length.


-- 
  Victor Leikehman
  IBM Research Labs in Haifa, Israel

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: trans-io.c.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20040815/7cd9c809/attachment.ksh>


More information about the Fortran mailing list