ieee_9.f90: XFAIL on arm*-*-gnueabi[hf].
[official-gcc.git] / gcc / testsuite / gfortran.dg / elemental_function_3.f90
blob67bdd1ea86fb58cbfdcad3fa413953cb08b4de63
1 ! { dg-do run }
3 ! Test the fix for PR84109 in which the call to the elemental function
4 ! 'adjustl' 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. This is the intrinsic counterpart to PR87239,
8 ! which is tested for the absence of an ICE in elemental_function_2.f90.
9 ! In this fix, a further improvement was to keep scalar calls outside the
10 ! scalarization loop and this is tested with 'my_adjustl'.
12 ! Contributed by Willem Vermin <wvermin@gmail.com>
14 program prog
15 implicit none
16 character(len=:), allocatable :: c(:)
17 integer :: cnt = 0
19 allocate(character(len=20) :: c(10))
20 c = " ab "
21 c = adjustl(c) ! Used to ICE
22 if (trim (c(1)) .ne. "ab") stop 1
24 c = my_adjustl (" abcdefg ")
25 if (trim (c(1)) .ne. "abcdefg") stop 2
26 if (cnt .ne. 1) stop 3 ! Outside the scalarization loop
27 if (size (c, 1) .ne. 10) stop 4
28 if (len (c) .ne. 20) stop 5
30 cnt = 0
31 c = my_adjustl ([" uv ", " xy "])
32 if (trim (c(2)) .ne. "xy") stop 6
33 if (cnt .ne. size (c, 1)) stop 7 ! Inside the scalarization loop
34 if (size (c, 1) .ne. 2) stop 8
36 contains
38 impure elemental function my_adjustl(arg) result (res)
39 character(*), intent(in) :: arg
40 character(len = len (arg)) :: res
41 res = adjustl (arg)
42 cnt = cnt + 1 ! Test how many calls are made
43 end function
44 end program