aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/allocatable_function_7.f90
blob: 755584ca1b660fc1b64123f2d1692c78c2cf5918 (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
! { dg-do run }
!
! PR fortran/56138
!
! Contributed by Dominique d'Humieres and John Chludzinski,
! using the code of John Reid
!
implicit none
interface
PURE FUNCTION s_to_c(string)
  CHARACTER(LEN=*),INTENT(IN)   :: string
  CHARACTER(LEN=:),ALLOCATABLE :: s_to_c
ENDFUNCTION s_to_c
end interface
CHARACTER(LEN=:),ALLOCATABLE :: str 
if (s_to_c("ABCdef") /= "ABCdef" .or. len(s_to_c("ABCdef")) /= 6) call abort()
str = s_to_c("ABCdef")
if (str /= "ABCdef" .or. len(str) /= 6) call abort()
str(1:3) = s_to_c("123")
if (str /= "123def" .or. len(str) /= 6) call abort()

end

PURE FUNCTION s_to_c(string) 
  CHARACTER(LEN=*),INTENT(IN)   :: string 
  CHARACTER(LEN=:),ALLOCATABLE :: s_to_c 
  s_to_c = string
END FUNCTION s_to_c