Debian Codegraph @

gcc/testsuite/gfortran.dg/c-interop/typecodes-array-char.f90

raw
1 ! PR 101305
2 ! PR 92482
3 ! { dg-do run }
4 ! { dg-additional-sources "typecodes-array-char-c.c dump-descriptors.c" }
5 ! { dg-additional-options "-g" }
6 !
7 ! This program tests that the character kind constants provided by
8 ! gfortran's ISO_C_BINDING module result in the right type field in
9 ! arguments passed by descriptor, also matching the size of the corresponding
10 ! C type. We use assumed-shape arrays to force the use of a descriptor.
11 !
12 ! FIXME: because of PR92482, we can only test len=1 characters. This
13 ! test should be extended once that bug is fixed.
14
15 program testit
16 use iso_c_binding
17 implicit none
18
19 integer, parameter :: ucs4 = selected_char_kind ('ISO_10646')
20
21 interface
22
23 subroutine ctest_1 (arg_cchar, arg_ucs4) bind (c)
24 use iso_c_binding
25 integer, parameter :: ucs4 = selected_char_kind ('ISO_10646')
26 character(kind=C_CHAR) :: arg_cchar(:)
27 character(kind=ucs4) :: arg_ucs4(:)
28 end subroutine
29
30 subroutine ctest_5 (arg_cchar, arg_ucs4) bind (c)
31 use iso_c_binding
32 integer, parameter :: ucs4 = selected_char_kind ('ISO_10646')
33 character(kind=C_CHAR,len=*) :: arg_cchar(:)
34 character(kind=ucs4,len=*) :: arg_ucs4(:)
35 end subroutine
36
37 end interface
38
39 character(kind=C_CHAR) :: var_cchar(4)
40 character(kind=ucs4) :: var_ucs4(4)
41 character(kind=C_CHAR,len=5) :: var_cchar_5(4)
42 character(kind=ucs4,len=5) :: var_ucs4_5(4)
43
44 call ctest_1 (var_cchar, var_ucs4)
45 call ctest_5 (var_cchar_5, var_ucs4_5)
46
47 end program