2014-07-12 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / allocatable_function_7.f90
blob755584ca1b660fc1b64123f2d1692c78c2cf5918
1 ! { dg-do run }
3 ! PR fortran/56138
5 ! Contributed by Dominique d'Humieres and John Chludzinski,
6 ! using the code of John Reid
8 implicit none
9 interface
10 PURE FUNCTION s_to_c(string)
11 CHARACTER(LEN=*),INTENT(IN) :: string
12 CHARACTER(LEN=:),ALLOCATABLE :: s_to_c
13 ENDFUNCTION s_to_c
14 end interface
15 CHARACTER(LEN=:),ALLOCATABLE :: str
16 if (s_to_c("ABCdef") /= "ABCdef" .or. len(s_to_c("ABCdef")) /= 6) call abort()
17 str = s_to_c("ABCdef")
18 if (str /= "ABCdef" .or. len(str) /= 6) call abort()
19 str(1:3) = s_to_c("123")
20 if (str /= "123def" .or. len(str) /= 6) call abort()
22 end
24 PURE FUNCTION s_to_c(string)
25 CHARACTER(LEN=*),INTENT(IN) :: string
26 CHARACTER(LEN=:),ALLOCATABLE :: s_to_c
27 s_to_c = string
28 END FUNCTION s_to_c