[fortran patch] Don't use TREE_LISTs for storing arguments to intrinsic functions

Lee Millward lee.millward@codesourcery.com
Wed May 9 08:35:00 GMT 2007


Hi Brooks,

On 5/9/07, Brooks Moses <brooks.moses@codesourcery.com> wrote:
> Am I correct in understanding that this is why you have things set up so
> that gfc_conv_intrinsic_aint (for example) declares args as a
> two-element array rather than a single value?  (Otherwise, I suppose it
> would trigger the "curr_arg < nargs" assertion if the KIND argument is
> present....)

Yes.

> I think this ends up being unfortunate in a number of ways.  The
> declaration of args in gfc_conv_intrinsic_aint as larger than we need is
> one of them, and the fact that we can't guarantee that the args array
> gets filled is another.  Thus, I would suggest rearranging things, as
> follows:
>
> (1) Change the main loop in gfc_conv_intrinsic_function_args to:
>
>    for (int curr_arg = 0; curr_arg < nargs; curr_arg++,
>         actual = actual->next,
>         formal = formal ? formal->next : NULL)
>
> (2) Remove the gcc_assert(curr_arg < nargs), and add gcc_assert(actual)
> in its place.
>
> The result of those two is that we guarantee that the args array gets
> filled, but we don't necessarily loop over the whole arglist.  That is,
> we now allow the arglist to be longer than the args array, and we no
> longer allow it to be shorter.  That leads to:
>
> (3) Change gfc_conv_intrinsic_aint and other similar functions to only
> call for one argument, rather than two.
>
> Oh, and:
>
> (4) Add a comment somewhere that says that we are explicitly ignoring
> arguments past nargs in the arglist, in order to account for trailing
> KIND arguments that are not included in the generated code.  :)
>
> Does that seem reasonable?

I'll get onto that later today and will report back with an updated patch.

> Thanks (and apologies for putting this through so many iterations!),
> - Brooks
>

No problem :-) Thanks for the detailed review!

Cheers,
Lee



More information about the Fortran mailing list