This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [Patch, fortran] PR29422 and PR29428 - allocatable component wrinkles


This was OK'd off-list by Erik Edelmann.

Cheers

Paul

:ADDPATCH fortran:

Well, these are the first, I suppose, of quite a few!

PR29422 is associated with the fact that resolve_transfer was not checking functions for IO suitability; this applies to derived types with pointer components, as well as allocatable, Try the testcase with allocatable => pointer on gcc-4.2. The fix is easy; allow functions to be tested as well as variables.

PR29428 concerns double calls to functions that result from a nullifcation of the rhs of an assignment of a derived type with allocatable components. It turns out that the nullify is unnecessary, being a left-over from an early version of the allocatable component patch, so the patch is to remove it. I discovered it whilst developing a fix for PR29371; changing pointer=>allocatable resulted in four lines of output, instead of three!

Both the testcases are those submitted by the reporters.

Dominique d'Humieres has pointed out to me that the arrays need to be normalised so that lbound is one, rather than for example, copying the array bounds of constructor elements. This is a rather substantial change, since it will hit various testcases too. I will not hurry to fix this because we have survived until the 9th of this month with incorrectly normalised bounds all over the place (PR29391). However, I will try to get it sorted on the timescale of a week. Dominique, would you be so kind as to submit a PR for this, please?

Regtested on AMD64/Cygwin_NT - OK for trunk?

Paul

2006-10-12 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/29422
   * resolve.c (resolve_transfer): Test functions for suitability
   for IO, as well as variables.

   PR fortran/29428
   * trans-expr.c (gfc_trans_scalar_assign): Remove nullify of
   rhs expression.

2006-10-12 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/29422
   * gfortran.dg/alloc_comp_constraint_4.f90: New test.

   PR fortran/29428
   * gfortran.dg/alloc_comp_assign_5.f90: New test.

------------------------------------------------------------------------

Index: gcc/fortran/trans-expr.c
===================================================================
*** gcc/fortran/trans-expr.c (revision 117628)
--- gcc/fortran/trans-expr.c (working copy)
*************** gfc_trans_scalar_assign (gfc_se * lse, g
*** 3261,3279 ****
fold_convert (TREE_TYPE (lse->expr), rse->expr));
/* Do a deep copy if the rhs is a variable, if it is not the
! same as the lhs. Otherwise, nullify the data fields so that the
! lhs retains the allocated resources. */
if (r_is_var)
{
tmp = gfc_copy_alloc_comp (ts.derived, rse->expr, lse->expr, 0);
tmp = build3_v (COND_EXPR, cond, build_empty_stmt (), tmp);
gfc_add_expr_to_block (&block, tmp);
}
- else
- {
- tmp = gfc_nullify_alloc_comp (ts.derived, rse->expr, 0);
- gfc_add_expr_to_block (&block, tmp);
- }
}
else
{
--- 3261,3273 ----
fold_convert (TREE_TYPE (lse->expr), rse->expr));
/* Do a deep copy if the rhs is a variable, if it is not the
! same as the lhs. */
if (r_is_var)
{
tmp = gfc_copy_alloc_comp (ts.derived, rse->expr, lse->expr, 0);
tmp = build3_v (COND_EXPR, cond, build_empty_stmt (), tmp);
gfc_add_expr_to_block (&block, tmp);
}
}
else
{
Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c (revision 117628)
--- gcc/fortran/resolve.c (working copy)
*************** resolve_transfer (gfc_code * code)
*** 4167,4173 ****
exp = code->expr;
! if (exp->expr_type != EXPR_VARIABLE)
return;
sym = exp->symtree->n.sym;
--- 4167,4174 ----
exp = code->expr;
! if (exp->expr_type != EXPR_VARIABLE
! && exp->expr_type != EXPR_FUNCTION)
return;
sym = exp->symtree->n.sym;


------------------------------------------------------------------------

2006-10-12 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29422
	* resolve.c (resolve_transfer): Test functions for suitability
	for IO, as well as variables.

	PR fortran/29428
	* trans-expr.c (gfc_trans_scalar_assign): Remove nullify of
	rhs expression.

2006-10-12 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29422
	* gfortran.dg/alloc_comp_constraint_4.f90: New test.

PR fortran/29428
* gfortran.dg/alloc_comp_assign_5.f90: New test.




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