PR tree-optimization/86415 - strlen() not folded for substrings within constant arrays
[official-gcc.git] / gcc / testsuite / gfortran.dg / elemental_initializer_1.f90
blob7280e2582b08b8931779c3fa4f586f477e0f62c1
1 ! { dg-do compile }
2 ! Tests the fix for elemental functions not being allowed in
3 ! specification expressions in pure procedures.
5 ! Testcase from iso_varying_string by Rich Townsend <rhdt@star.ucl.ac.uk>
6 ! The allocatable component has been changed to a pointer for this testcase.
8 module iso_varying_string
10 type varying_string
11 private
12 character(LEN=1), dimension(:), pointer :: chars
13 end type varying_string
15 interface len
16 module procedure len_
17 end interface len
19 contains
21 pure function char_auto (string) result (char_string)
22 type(varying_string), intent(in) :: string
23 character(LEN=len(string)) :: char_string ! Error was here
24 char_string = ""
25 end function char_auto
27 elemental function len_ (string) result (length)
28 type(varying_string), intent(in) :: string
29 integer :: length
30 length = 1
31 end function len_
33 end module iso_varying_string