Debian Codegraph @

gcc/testsuite/gfortran.dg/c_sizeof_1.f90

raw
1 ! { dg-do run }
2 ! Support F2008's c_sizeof()
3 !
4 use iso_c_binding, only: c_int, c_char, c_ptr, c_intptr_t, c_null_ptr, c_sizeof
5
6 integer(kind=c_int) :: i, j(10)
7 character(kind=c_char,len=4),parameter :: str(1 ) = "abcd"
8 character(kind=c_char,len=1),parameter :: str2(4) = ["a","b","c","d"]
9 type(c_ptr) :: cptr
10 integer(c_intptr_t) :: iptr
11
12 ! Using F2008's C_SIZEOF
13 i = c_sizeof(i)
14 if (i /= 4) STOP 1
15
16 i = c_sizeof(j)
17 if (i /= 40) STOP 2
18
19 i = c_sizeof(str2)
20 if (i /= 4) STOP 3
21
22 i = c_sizeof(str2(1))
23 if (i /= 1) STOP 4
24
25 write(*,*) c_sizeof(cptr), c_sizeof(iptr), c_sizeof(C_NULL_PTR)
26
27 ! Using GNU's SIZEOF
28 i = sizeof(i)
29 if (i /= 4) STOP 5
30
31 i = sizeof(j)
32 if (i /= 40) STOP 6
33
34 i = sizeof(str)
35 if (i /= 4) STOP 7
36
37 i = sizeof(str(1))
38 if (i /= 4) STOP 8
39
40 i = sizeof(str(1)(1:3))
41 if (i /= 3) STOP 9
42
43 end
44