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

FX Coudert fxcoudert@gmail.com
Mon May 28 18:12:00 GMT 2007


I'll let Brooks give the final review, but I noted a problem with it  
because I'm working on a patch to gfc_conv_intrinsic_minmax() that  
builds on top of yours.

> @@ -1381,13 +1415,18 @@ gfc_conv_intrinsic_minmax (gfc_se * se,
>    tree val;
>    tree thencase;
>    tree elsecase;
> -  tree arg;
>    tree type;
> +  tree *args;
> +  unsigned int num_args;
> +  unsigned int i;
> +
> +  num_args = gfc_intrinsic_argument_list_length (expr);
> +  args = alloca (sizeof (tree) * num_args);
> -  arg = gfc_conv_intrinsic_function_args (se, expr);
> +  gfc_conv_intrinsic_function_args (se, expr, args, num_args);
>    type = gfc_typenode_for_spec (&expr->ts);
> -  limit = TREE_VALUE (arg);
> +  limit = args[0];
>    if (TREE_TYPE (limit) != type)
>      limit = convert (type, limit);
>    /* Only evaluate the argument once.  */
> @@ -1396,9 +1435,9 @@ gfc_conv_intrinsic_minmax (gfc_se * se,
>    mvar = gfc_create_var (type, "M");
>    elsecase = build2_v (MODIFY_EXPR, mvar, limit);
> -  for (arg = TREE_CHAIN (arg); arg != NULL_TREE; arg = TREE_CHAIN  
> (arg))
> +  for (i = 0; i < num_args; i++)
>      {
> -      val = TREE_VALUE (arg);
> +      val = args[i];
>        if (TREE_TYPE (val) != type)
> 	val = convert (type, val);

I think the for-loop at then end of that hunk should start with i =  
1. Otherwise, the generated code for MAX(a,b) start with comparing "a  
 > a". Can you check that?

FX



More information about the Fortran mailing list