Debian Codegraph @

gcc/testsuite/gfortran.dg/elemental_function_2.f90

raw
1 ! { dg-do compile }
2 !
3 ! Test the fix for PR87239 in which the call to the elemental function
4 ! 'gettwo' was being added before the scalarization loop in the assignment.
5 ! Since the result temporary was being declared in the loop body, this
6 ! drove the gimplifier crazy. It is sufficient to compile this testcase
7 ! since it used to ICE.
8 !
9 ! Contributed by Juergen Reuter <[email protected]>
10 !
11 module test
12 implicit none
13 contains
14
15 elemental function gettwo( s ) result( res )
16 character(*), intent(in) :: s
17 character(len(s)) :: res
18
19 res = s( 1 : 2 )
20 endfunction gettwo
21
22 endmodule test
23
24 program main
25 use test
26 implicit none
27 character(10) :: inp( 5 )
28 integer :: i
29
30 ! character(10), allocatable :: out(:) ! this works
31 character(:), allocatable :: out(:) ! this was stuffed
32
33 inp = [ 'aaa', 'bbb', 'ccc', 'ddd', 'eee' ]
34
35 out = gettwo( inp )
36
37 do i = 1, size (out, 1)
38 if (trim (out(i)) .ne. inp(i)(1:2)) stop 1
39 end do
40 endprogram main