| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! PR fortran/85781 |
| 4 |
! |
| 5 |
! Co-contributed by G. Steinmetz |
| 6 |
|
| 7 |
use iso_c_binding, only: c_char |
| 8 |
call s(c_char_'x', 1, 1) |
| 9 |
call s(c_char_'x', 1, 0) |
| 10 |
call s(c_char_'x', 0, -2) |
| 11 |
contains |
| 12 |
subroutine s(x,m,n) bind(c) |
| 13 |
use iso_c_binding, only: c_char |
| 14 |
character(kind=c_char), value :: x |
| 15 |
call foo(x(m:n), m, n) |
| 16 |
if (n < m) then |
| 17 |
if (len(x(m:n)) /= 0) stop 1 |
| 18 |
if (x(m:n) /= "") stop 2 |
| 19 |
else if (n == 1) then |
| 20 |
if (len(x(m:n)) /= 1) stop 1 |
| 21 |
if (x(m:n) /= "x") stop 2 |
| 22 |
else |
| 23 |
stop 14 |
| 24 |
end if |
| 25 |
call foo(x(1:1), 1, 1) |
| 26 |
call foo(x(1:0), 1, 0) |
| 27 |
call foo(x(2:1), 2, 1) |
| 28 |
call foo(x(0:-4), 0, -4) |
| 29 |
|
| 30 |
call foo(x(1:), 1, 1) |
| 31 |
call foo(x(2:), 2, 1) |
| 32 |
call foo(x(:1), 1, 1) |
| 33 |
call foo(x(:0), 1, 0) |
| 34 |
|
| 35 |
if (n == 1) call foo(x(m:), m, n) |
| 36 |
if (m == 1) call foo(x(:n), m, n) |
| 37 |
end |
| 38 |
subroutine foo(str, m, n) |
| 39 |
character(len=*) :: str |
| 40 |
if (n < m) then |
| 41 |
if (len(str) /= 0) stop 11 |
| 42 |
if (str /= "") stop 12 |
| 43 |
else if (n == 1) then |
| 44 |
if (len(str) /= 1) stop 13 |
| 45 |
if (str /= "x") stop 14 |
| 46 |
else |
| 47 |
stop 14 |
| 48 |
end if |
| 49 |
end |
| 50 |
end |