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

--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
! { dg-do run }
!
! Check that pointer assignments allowed by F2003:C717
! work and check null initialization of CLASS(*) pointers.
!
! Contributed by Tobias Burnus <bur...@gcc.gnu.org>
!
program main
  interface
    subroutine foo(z)
      class(*), pointer, intent(in) :: z
    end subroutine foo
  end interface
  type sq
    sequence
    integer :: i
  end type sq
  type(sq), target :: x
  class(*), pointer :: y, z
  x%i = 42
  y => x
  z => y ! unlimited => unlimited allowed
  call foo (z)
  call bar
contains
  subroutine bar
    type t
    end type t
    type(t), pointer :: x
    class(*), pointer :: ptr1 => null() ! pointer initialization
    if (same_type_as (ptr1, x) .neqv. .FALSE.) STOP 1
  end subroutine bar

end program main


subroutine foo(tgt)
  class(*), pointer, intent(in) :: tgt
  type sq
    sequence
    integer :: i
  end type sq
  type(sq), pointer :: ptr
  ptr => tgt ! sequence type => unlimited allowed
  if (ptr%i .ne. 42) STOP 2
end subroutine foo

works with your patch and doesn't without it.
But, if I change sq in foo to s, it doesn't work anymore.  Though, seems even
type name and all member names are important, so I think we should just
change the testcase to the above and perhaps add another one with bind(c)
derived type instead of the sequence one.

Reply via email to