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

--- Comment #4 from anlauf at gcc dot gnu.org ---
(In reply to Steve Kargl from comment #3)
> This patch allows Ivan's code to compile and execute.
> It is otherwise untested.
> 
> diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
> index a47e970eda9..4cd90d88050 100644
> --- a/gcc/fortran/expr.cc
> +++ b/gcc/fortran/expr.cc
> @@ -6557,8 +6557,14 @@ gfc_is_not_contiguous (gfc_expr *array)
>      {
>        /* Array-ref shall be last ref.  */
>  
> -      if (ar && ar->type != AR_ELEMENT)
> -     return true;
> +      if (ar)
> +     {
> +       /* Check for 'a(:)%x'  */
> +       if (ref->type == REF_COMPONENT)
> +         return gfc_is_simply_contiguous (array, false, false);

Is this the right logic?  Shouldn't it be inverted?

> +       else if (ar->type != AR_ELEMENT)
> +         return true;
> +     }
>  
>        if (ref->type == REF_ARRAY)
>       ar = &ref->u.ar;

I am still struggling with F2023 8.5.7 CONTIGUOUS attribute, which has:

An object is contiguous if it is
...
(7) a nonzero‑sized array section (9.5.3) provided that
...
   (f) only its final part‑ref has nonzero rank, and
...

Isn't this violated by the testcase in comment#0?

Reply via email to