2 ! Test the fix for PR55618, in which character scalar function arguments to
3 ! elemental functions would gain an extra indirect reference thus causing
4 ! failures in Vst17.f95, Vst 30.f95 and Vst31.f95 in the iso_varying_string
5 ! testsuite, where elemental tests are done.
7 ! Reported by Tobias Burnus <burnus@gcc.gnu.org>
9 integer, dimension (2) :: i
= [1,2]
11 character (len
= 2) :: chr1
= "lm"
12 character (len
= 1), dimension (2) :: chr2
= ["r", "s"]
13 if (any (foo (i
, bar()) .ne
. ["a", "b"])) call abort
! This would fail
14 if (any (foo (i
, "xy") .ne
. ["x", "y"])) call abort
! OK - not a function
15 if (any (foo (i
, chr1
) .ne
. ["l", "m"])) call abort
! ditto
16 if (any (foo (i
, char (j
)) .ne
. ["A", "B"])) call abort
! This would fail
17 if (any (foo (i
, chr2
) .ne
. ["s", "u"])) call abort
! OK - not a scalar
18 if (any (foo (i
, bar2()) .ne
. ["e", "g"])) call abort
! OK - not a scalar function
20 elemental
character(len
= 1) function foo (arg1
, arg2
)
21 integer, intent (in
) :: arg1
22 character(len
= *), intent (in
) :: arg2
23 if (len (arg2
) > 1) then
26 foo
= char (ichar (arg2
) + arg1
)
29 character(len
= 2) function bar ()
32 function bar2 () result(res
)
33 character (len
= 1), dimension(2) :: res