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] PR36528 - Cray pointer to function mishandled


Dear Tobias,

No sooner did I write this than a simple solution became clear:

trans-expr.c:

1509,1510c1509,1513
< 	tmp = convert (build_pointer_type (TREE_TYPE (tmp)),
< 		       gfc_get_symbol_decl (sym->cp_pointer));
---
> 	{
> 	  tmp = convert (build_pointer_type (TREE_TYPE (tmp)),
> 		         gfc_get_symbol_decl (sym->cp_pointer));
> 	  tmp = gfc_evaluate_now (tmp, &se->pre);
> 	}
1516a1520
>
2626c2630,2641
< 	      if (fsym && fsym->attr.value)
---
> 	      if (fsym && fsym->attr.flavor == FL_PROCEDURE
> 		    && e->expr_type == EXPR_VARIABLE
> 		    && e->symtree->n.sym->attr.cray_pointee)
> 		{
> 		    /* The Cray pointer needs to be converted to a pointer type
> 		       pointee.  The symbol gives the pointee address.  */
> 		    gfc_conv_expr (&parmse, e);
> 		    type = build_pointer_type (TREE_TYPE (parmse.expr));
> 		    tmp = gfc_get_symbol_decl (e->symtree->n.sym->cp_pointer);
> 		    parmse.expr = convert (type, tmp);
> 		}
> 	      else if (fsym && fsym->attr.value)

This generates a call from 'p' in PR36701 as follows:
      D.1750 = (void (*<T468>) (struct array1_unknown &,
integer(kind=4), struct array1_integer(kind=4) &)) p;
      D.1750 (&atmp.33, MAX_EXPR <D.1732, 0>, D.1726);

I think that achieves exactly what is needed, albeit at the expense of
a pointer assignment for each call.  However, this is intrinsic to the
Cray pointer mechanism, as it is implemented in gfortran.

I'll see if I cannot regtest this before going away.

Paul


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