Debian Codegraph @

gcc/testsuite/gfortran.dg/c_sizeof_7.f90

raw
1 ! { dg-do compile }
2 ! PR fortran/106500 - fix checking of arguments to C_SIZEOF
3 !
4 ! Check support of the following EDIT to 18-007r1:
5 ! https://j3-fortran.org/doc/year/22/22-101r1.txt
6
7 subroutine foo (n, x, y, z, w, u)
8 use, intrinsic :: iso_c_binding
9 implicit none
10 integer, intent(in) :: n
11 real :: x(n)
12 real :: y(:)
13 real :: z(2,*)
14 real :: w(..)
15 real, allocatable :: a(:)
16 real, pointer :: b(:)
17 type t
18 real, allocatable :: a(:)
19 end type t
20 type(t) :: u
21
22 print *, c_sizeof (x)
23 print *, c_sizeof (x(::2))
24 print *, c_sizeof (x+1)
25 print *, c_sizeof (y)
26 print *, c_sizeof (y(1:2))
27 print *, c_sizeof (z(:,1:2))
28 print *, c_sizeof (w)
29 print *, c_sizeof (1._c_float)
30 !
31 allocate (a(n))
32 allocate (b(n))
33 if (.not. allocated (u%a)) allocate (u%a(n))
34 print *, c_sizeof (a)
35 print *, c_sizeof (b)
36 !
37 print *, c_sizeof (u%a)
38 print *, c_sizeof (u%a(1:2))
39 !
40 print *, c_sizeof (z) ! { dg-error "Assumed-size arrays are not interoperable" }
41 print *, c_sizeof (u) ! { dg-error "Expression is a noninteroperable derived type" }
42 end