https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125998

--- Comment #9 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Harald Anlauf from comment #5)
> Created attachment 64866 [details]
> Untested fix
> 
> gfc_is_not_contiguous should return true on TRANSPOSE (array).
That was my first reaction, and then I thought array could itself be a
transposed array, so that TRANSPOSE(array) _is_ contiguous.

(In reply to Harald Anlauf from comment #6)
> I also thought about
> 
> diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
> index 04f0c513a7d..6dba193e17d 100644
> --- a/gcc/fortran/expr.cc
> +++ b/gcc/fortran/expr.cc
> @@ -6556,6 +6556,11 @@ gfc_is_not_contiguous (gfc_expr *array)
>    gfc_ref *ref;
>    bool previous_incomplete;
>  
> +  /* For function results fall back to gfc_is_simply_contiguous.
> +     E.g. intrinsic TRANSPOSE rewrites the array descriptor.  */
> +  if (array->expr_type == EXPR_FUNCTION)
> +    return !gfc_is_simply_contiguous (array, false, true);
> +
>    for (ref = array->ref; ref; ref = ref->next)
>      {
>        /* Array-ref shall be last ref.  */
> 
> as a slightly more "general" solution,
This would be wrong, I think, for pointer-returning functions, which are not
simply contiguous, but can be contiguous.

> but am unable to construct an
> example where transposed dimensions occur and which can be passed to
> target, contiguous dummy which can be associated with the actual.
I don't understand what you are looking for.  The original testcase doesn't
fit?

(In reply to Harald Anlauf from comment #7)
> Another part of the issue is that gfc_expr_is_variable has:
> 
>   arg = gfc_get_noncopying_intrinsic_argument (expr);
>   if (arg)
>     {
>       gcc_assert (expr->value.function.isym->id == GFC_ISYM_TRANSPOSE);
>       return gfc_expr_is_variable (arg);
>     }
> 
> This seems to be your code, Mikael.
> We could try to suppress this exception.
Heh, no, the exception is important to gfc_expr_is_variable.

(In reply to Harald Anlauf from comment #8)
> (In reply to Harald Anlauf from comment #7)
> > This seems to be your code, Mikael.
> > We could try to suppress this exception.
> 
> Like:
> 
> diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
> index 9108e92b446..a18701763e2 100644
> --- a/gcc/fortran/trans-expr.cc
> +++ b/gcc/fortran/trans-expr.cc
> @@ -8045,6 +8047,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
>                          ? gfc_is_not_contiguous (e)
>                          : !gfc_is_simply_contiguous (e, false, true))
>                      && gfc_expr_is_variable (e)
> +                    && gfc_get_noncopying_intrinsic_argument (e) == NULL
>                      && e->rank != -1)
>               {
>                 gfc_conv_subref_array_arg (&parmse, e, nodesc_arg,
OK, like this it's acceptable.

I have the impression that the problem is more in gfc_conv_subref_array_arg
though.

Reply via email to