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

--- Comment #5 from Steve Kargl <kargl at gcc dot gnu.org> ---
(In reply to anlauf from comment #4)
> (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?

Good catch.  The logic is indeed backwards.

> > +     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?

I think that (7) does not apply here.

c => a%x   ! False error?

'a' is a whole array.  Wouldn't (7) apply to something
like 'c => a(2:3)%x'

It seems we have

  An object is contiguous if it is
  ...
  (2) a nonpointer whole array that is not assumed-shape,

I suppose one can argument that 'a%x' may not be a whole array;
in particular, if we have

type :: t1
  real :: x
  integer :: i
end type

then 3.38 seems to apply.


3.37
contiguous
<array> whose array elements, in order, are not separated by other data objects

3.38
contiguous
<multi-part data object> whose parts, in order, are not
separated by other data objects

Reply via email to