2014-01-30 Alangi Derick <alangiderick@gmail.com>
[official-gcc.git] / gcc / testsuite / gfortran.dg / char_result_13.f90
blob638d6381e19b9a20f5e4012bb74a868178a68ee6
1 ! { dg-do run }
2 ! Tests the fix for PR38538, where the character length for the
3 ! argument of 'func' was not calculated.
5 ! Contributed by Vivek Rao <vivekrao4@yahoo.com>
7 module abc
8 implicit none
9 contains
10 subroutine xmain (i, j)
11 integer i, j
12 call foo (func ("_"//bar (i)//"x"//bar (j)//"x"), "_abcxabx") ! original was elemental
13 call foo (nfunc("_"//bar (j)//"x"//bar (i)//"x"), "_abxabcx")
14 end subroutine xmain
16 function bar (i) result(yy)
17 integer i, j, k
18 character (len = i) :: yy(2)
19 do j = 1, size (yy, 1)
20 do k = 1, i
21 yy(j)(k:k) = char (96+k)
22 end do
23 end do
24 end function bar
26 elemental function func (yy) result(xy)
27 character (len = *), intent(in) :: yy
28 character (len = len (yy)) :: xy
29 xy = yy
30 end function func
32 function nfunc (yy) result(xy)
33 character (len = *), intent(in) :: yy(:)
34 character (len = len (yy)) :: xy(size (yy))
35 xy = yy
36 end function nfunc
38 subroutine foo(cc, teststr)
39 character (len=*), intent(in) :: cc(:)
40 character (len=*), intent(in) :: teststr
41 if (any (cc .ne. teststr)) call abort
42 end subroutine foo
43 end module abc
45 use abc
46 call xmain(3, 2)
47 end