summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/proc_decl_23.f90
blob: 66cf5fff736efa6307db9b356666f42fdd464ab6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
! { dg-do compile }
! Test the fix for PR43227, in which the lines below would segfault.
!
! Dominique d'Humieres <dominiq@lps.ens.fr>
!
function char1 (s) result(res)
  character, dimension(:), intent(in) :: s
  character(len=size(s)) :: res
  do i = 1, size(s)
    res(i:i) = s(i)
  end do
end function char1

module m_string

  procedure(string_to_char) :: char1                    ! segfault
  procedure(string_to_char), pointer :: char2           ! segfault
  type t_string
    procedure(string_to_char), pointer, nopass :: char3 ! segfault
  end type t_string

contains

  function string_to_char (s) result(res)
    character, dimension(:), intent(in) :: s
    character(len=size(s)) :: res
    do i = 1, size(s)
      res(i:i) = s(i)
    end do
  end function string_to_char

end module m_string

  use m_string
  type(t_string) :: t
  print *, string_to_char (["a","b","c"])
  char2 => string_to_char
  print *, char2 (["d","e","f"])
  t%char3 => string_to_char
  print *, t%char3 (["g","h","i"])
  print *, char1 (["j","k","l"])
end
! { dg-final { cleanup-tree-dump "m_string" } }
! { dg-final { cleanup-modules "m_string" } }