[PATCH, fortran] reduce character array parameters (PR fortran/22491)
David Edelsohn
dje@watson.ibm.com
Fri Jul 22 14:55:00 GMT 2005
I am not certain about where the parameter simplification
implemented in my patch should occur. The relevant portion of
simplify_parameter_variable() is:
e = gfc_copy_expr (p->symtree->n.sym->value);
if (e->expr_type != EXPR_CONSTANT && p->ref != NULL)
e->ref = copy_ref (p->ref);
t = gfc_simplify_expr (e, type);
For the array example in the PR,
character*2 a(1)
p->symtree->n.sym->value is an EXPR_CONSTANT. gfc_copy_expr copies the
ref for the value, which is NULL, and simplify_parameter_variable()
replaces the copied ref with the ref from the parent object.
My question is whether the subobject ref should be stripped after
the copy, as I propose in my patch, or should be stripped in
gfc_simplify_expr(), or in both. Stripping unnecessary refs is a
simplification.
My sense is that when simplify_parameter_variable() creates the
new expression, it should set the ref correctly as well. Is that a
correct expectation or should gfc_simplify_expr() clean it up?
Also, I do not know if gfc_simplify_expr() could be called on
other paths with an EXPR_CONSTANT with associated subobject refs that
should be cleared. Should gfc_simplify_expr() perform that
simplification?
Thanks, David
More information about the Fortran
mailing list