On Sat, Jan 24, 2015 at 07:21:27PM +0100, Tobias Burnus wrote:
> gfortran's scalar coarray are special: The descriptorless variant is a
> normal variable with some language-specific additional information (corank,
> bounds). The descriptor variant has a descriptor but the _data component is
> just a pointer to the scalar variable.
> 
> As the element type of a descriptorless coarray is the type itself, we need
> to break the while loop.
> 
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?

Won't that break e.g.

subroutine foo
  type x
    integer, allocatable :: y
  end type
  type(x) :: z(2, 2)
  !$omp parallel private (z)
    allocate (z(2, 2)%y)
  !$omp end parallel
end subroutine

In that case I believe we have GFC_ARRAY_TYPE_P and !GFC_DESCRIPTOR_TYPE_P,
and GFC_TYPE_ARRAY_RANK (type) is 2, and the struct has allocatable
components, but we would return that we don't have them?

> --- a/gcc/fortran/trans-openmp.c
> +++ b/gcc/fortran/trans-openmp.c
> @@ -189,7 +189,8 @@ gfc_has_alloc_comps (tree type, tree decl)
>       return false;
>      }
>  
> -  while (GFC_DESCRIPTOR_TYPE_P (type) || GFC_ARRAY_TYPE_P (type))
> +  if (GFC_DESCRIPTOR_TYPE_P (type)
> +      || (GFC_ARRAY_TYPE_P (type) && GFC_TYPE_ARRAY_RANK (type) == 0))
>      type = gfc_get_element_type (type);
>  
>    if (TREE_CODE (type) != RECORD_TYPE)

        Jakub

Reply via email to