summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/elemental_initializer_1.f90
blob: 0e717c947d21c7f383b1cb01c768091cc7feca06 (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
! { dg-do compile }
! Tests the fix for elemental functions not being allowed in
! specification expressions in pure procedures.
!
! Testcase from iso_varying_string by Rich Townsend <rhdt@star.ucl.ac.uk>
! The allocatable component has been changed to a pointer for this testcase.
!
module iso_varying_string

  type varying_string
     private
     character(LEN=1), dimension(:), pointer :: chars
  end type varying_string

  interface len
     module procedure len_
  end interface len

contains

  pure function char_auto (string) result (char_string)
    type(varying_string), intent(in) :: string
    character(LEN=len(string))       :: char_string ! Error was here
    char_string = ""
  end function char_auto

  elemental function len_ (string) result (length)
    type(varying_string), intent(in) :: string
    integer                          :: length
    length = 1
  end function len_

end module iso_varying_string

! { dg-final { cleanup-modules "iso_varying_string" } }