Debian Codegraph @

gcc/testsuite/gfortran.dg/c_char_tests.f03

raw
1 ! { dg-do run }
2 ! { dg-additional-sources c_char_driver.c }
3 ! Verify that character dummy arguments for bind(c) procedures can work both
4 ! by-value and by-reference when called by either C or Fortran.
5 ! PR fortran/32732
6 module c_char_tests
7 use, intrinsic :: iso_c_binding, only: c_char
8 implicit none
9 contains
10 subroutine param_test(my_char, my_char_2) bind(c)
11 character(c_char), value :: my_char
12 character(c_char), value :: my_char_2
13 if(my_char /= c_char_'y') STOP 1
14 if(my_char_2 /= c_char_'z') STOP 2
15
16 call sub1(my_char)
17 end subroutine param_test
18
19 subroutine sub0() bind(c)
20 call param_test('y', 'z')
21 end subroutine sub0
22
23 subroutine sub1(my_char_ref) bind(c)
24 character(c_char) :: my_char_ref
25 if(my_char_ref /= c_char_'y') STOP 3
26 end subroutine sub1
27 end module c_char_tests