Debian Codegraph @

gcc/testsuite/gfortran.dg/bind_c_char_3.f90

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