On Sun, Jul 13, 2025 at 10:59:32AM +0200, Mikael Morin wrote:
> 
> Regression tested on x86_64-pc-linux-gnu.
> OK for master?
> 

Yes, with one observation below.

> diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
> index 1561936daf1..af62e17442b 100644
> --- a/gcc/fortran/trans-array.cc
> +++ b/gcc/fortran/trans-array.cc
> @@ -3437,6 +3437,148 @@ save_descriptor_data (tree descr, tree data)
>  }
>  
>  
> +/* Type of the DATA argument passed to walk_tree by 
> substitute_subexpr_in_expr
> +   and used by maybe_substitute_expr.  */
> +
> +typedef struct 
> +{
> +  tree target, repl;
> +}
> +substitute_t;
> +
> +
> +/* Check if the expression in *TP is equal to the substitution target 
> provided
> +   in DATA->TARGET and replace it with DATA->REPL in that case.   This is a
> +   callback function for use with walk_tree.  */
> +   
> +static tree
> +maybe_substitute_expr (tree *tp, int *walk_subtree, void *data)
> +{
> +  substitute_t *subst = (substitute_t *) data;
> +  if (*tp == subst->target)
> +    {
> +      *tp = subst->repl;
> +      *walk_subtree = 0;
> +    }
> +
> +  return NULL_TREE;
> +}


Can you explain why the above function always
returns NULL_TREE?  It would seem to me that
that function could be declared "static void"
or "static void *".  Is this simply to avoid 
a ...

> +
> +/* Substitute in EXPR any occurence of TARGET with REPLACEMENT.  */
> +
> +static void
> +substitute_subexpr_in_expr (tree target, tree replacement, tree expr)
> +{
> +  substitute_t subst;
> +  subst.target = target;
> +  subst.repl = replacement;
> +
> +  walk_tree (&expr, maybe_substitute_expr, &subst, nullptr);

cast here?

-- 
Steve

Reply via email to