2 ! Test the fix for PR26891, in which an optional argument, whose actual
3 ! is a missing dummy argument would cause a segfault.
5 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
7 logical :: back
=.false
.
9 ! This was the case that would fail - PR case was an intrinsic call.
10 if (scan ("A quick brown fox jumps over the lazy dog", "lazy", back
) &
11 .ne
. myscan ("A quick brown fox jumps over the lazy dog", "lazy")) &
14 ! Check that the patch works with non-intrinsic functions.
15 if (myscan ("A quick brown fox jumps over the lazy dog", "fox", back
) &
16 .ne
. thyscan ("A quick brown fox jumps over the lazy dog", "fox")) &
19 ! Check that missing, optional character actual arguments are OK.
20 if (scan ("A quick brown fox jumps over the lazy dog", "over", back
) &
21 .ne
. thyscan ("A quick brown fox jumps over the lazy dog")) &
25 integer function myscan (str
, substr
, back
)
26 character(*), intent(in
) :: str
, substr
27 logical, optional
, intent(in
) :: back
28 myscan
= scan (str
, substr
, back
)
31 integer function thyscan (str
, substr
, back
)
32 character(*), intent(in
) :: str
33 character(*), optional
, intent(in
) :: substr
34 logical, optional
, intent(in
) :: back
35 thyscan
= isscan (str
, substr
, back
)
38 integer function isscan (str
, substr
, back
)
39 character(*), intent(in
) :: str
40 character(*), optional
:: substr
41 logical, optional
, intent(in
) :: back
42 if (.not
.present(substr
)) then
43 isscan
= myscan (str
, "over", back
)
45 isscan
= myscan (str
, substr
, back
)