2010-07-27 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc/alias-decl.git] / gcc / testsuite / gfortran.dg / c_sizeof_1.f90
blobb30bdc5285e9f069593ea4a8a56807db7c38c6e9
1 ! { dg-do run }
2 ! Support F2008's c_sizeof()
4 use iso_c_binding, only: c_int, c_char, c_ptr, c_intptr_t, c_null_ptr
6 integer(kind=c_int) :: i, j(10)
7 character(kind=c_char,len=4),parameter :: str(1) = "abcd"
8 type(c_ptr) :: cptr
9 integer(c_intptr_t) :: iptr
11 ! Using F2008's C_SIZEOF
12 i = c_sizeof(i)
13 if (i /= 4) call abort()
15 i = c_sizeof(j)
16 if (i /= 40) call abort()
18 i = c_sizeof(str)
19 if (i /= 4) call abort()
21 i = c_sizeof(str(1))
22 if (i /= 4) call abort()
24 i = c_sizeof(str(1)(1:3))
25 if (i /= 3) call abort()
27 write(*,*) c_sizeof(cptr), c_sizeof(iptr), c_sizeof(C_NULL_PTR)
29 ! Using GNU's SIZEOF
30 i = sizeof(i)
31 if (i /= 4) call abort()
33 i = sizeof(j)
34 if (i /= 40) call abort()
36 i = sizeof(str)
37 if (i /= 4) call abort()
39 i = sizeof(str(1))
40 if (i /= 4) call abort()
42 i = sizeof(str(1)(1:3))
43 if (i /= 3) call abort()
45 end