This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR24276 Components of a derived type array not passed as an array
- From: Tobias dot Schlueter at Physik dot Uni-Muenchen dot DE
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Cc: Paul Thomas <paulthomas2 at wanadoo dot fr>
- Date: Fri, 20 Jan 2006 11:48:13 +0100
- Subject: Re: [Patch, fortran] PR24276 Components of a derived type array not passed as an array
Hi Paul,
sorry for taking so long. The patch is not yet ok, see below. (Sorry, that I'm
not correctly following up in the thread.)
> + /* Returns a reference to a temporary array into which a component of
> + an actual argument derived type array is copied and then returned
> + after the function call.
> + TODO Get rid of this kludge, when array descriptors are capable of
> + handling aliassed arrays. */
'aliased' instead of 'aliassed', but since 'aliasing' means something different,
(namely, two symbols pointing to the same memory location), maybe an altogether
different word would be appropriate?
+ for (n = info->dimen - 1 ;n >= 0 ;n--)
Exchange semicolons and blanks.
> + {
> + if (n > 0)
> + {
> + tree tmp_str;
> + tmp = rse.loop->loopvar[n];
> + tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type,
> + tmp, rse.loop->from[n]);
> + tmp = fold_build2 (PLUS_EXPR, gfc_array_index_type,
> + tmp, tmp_index);
> +
> + tmp_str = fold_build2 (MINUS_EXPR, gfc_array_index_type,
> + rse.loop->to[n-1], rse.loop->from[n-1]);
> + tmp_str = fold_build2 (PLUS_EXPR, gfc_array_index_type,
> + tmp_str, gfc_index_one_node);
> +
> + tmp_index = fold_build2 (MULT_EXPR, gfc_array_index_type,
> + tmp, tmp_str);
> + }
> + else
> + {
> + tmp_index = fold_build2 (MINUS_EXPR, gfc_array_index_type,
> + tmp_index, rse.loop->from[n]);
> + gfc_add_modify_expr (&rse.loop->code[n], offset, tmp_index);
> +
> + tmp_index = fold_build2 (PLUS_EXPR, gfc_array_index_type,
> + rse.loop->loopvar[n], offset);
> + }
> + }
You're not using the tmp_index built for n > 1 anywhere. You should pull the
else branch out of the loop, and change the termination condition to n > 0.
I'm not sure if the not-using of the tmp_index' is an error, otherwise you
could completely do away with the loop.
Thank you,
- Tobi