Fix compilation failure with C++98 compilers
[official-gcc.git] / gcc / testsuite / gfortran.dg / sizeof_4.f90
blob8c93408684456314fb7ffa2ffb40fc99192a1914
1 ! { dg-do run }
3 ! PR fortran/61881
4 ! PR fortran/61888
7 use iso_c_binding
8 implicit none
10 call dim0(5, 4)
12 call dim1([1, 2, 3], 4*3)
14 call dimd(5, 4)
15 call dimd([1, 2, 3], 4*3)
16 call dimd(reshape([1, 4, 2, 3],[2, 2]), 4*4)
18 call tdim1([1, 2, 3], 4*3)
19 call tdim1([1_8, 2_8, 3_8], 8*3)
21 call tdimd(5, 4)
22 call tdimd([1, 2, 3], 4*3)
23 call tdimd(reshape([1, 4, 2, 3], [2, 2]), 4*4)
24 call tdimd(5_8, 8)
25 call tdimd([1_8, 2_8, 3_8], 8*3)
26 call tdimd(reshape([1_8, 4_8, 2_8, 3_8],[2,2]), 8*4)
28 call cdim0(5, 4)
30 call cdim1([1, 2, 3], 4*3)
32 call cdimd(5, 4)
33 call cdimd([1, 2, 3], 4*3)
34 call cdimd(reshape([1,4,2,3],[2,2]), 4*4)
35 call cdimd(5_8, 8)
36 call cdimd([1_8, 2_8, 3_8], 8*3)
37 call cdimd(reshape([1_8, 4_8, 2_8, 3_8], [2, 2]), 8*4)
39 contains
41 subroutine dim0(x, expected_size)
42 integer :: x
43 integer, value :: expected_size
44 if (sizeof(x) /= expected_size) STOP 1
45 if (storage_size(x)/8 /= expected_size) STOP 2
46 end
48 subroutine dim1(x, expected_size)
49 integer, dimension(:) :: x
50 integer, value :: expected_size
51 if (sizeof(x) /= expected_size) STOP 3
52 if (storage_size(x)/8*size(x) /= expected_size) STOP 4
53 end
55 subroutine dimd(x, expected_size)
56 integer, dimension(..) :: x
57 integer, value :: expected_size
58 if (sizeof(x) /= expected_size) STOP 5
59 if (storage_size(x)/8*size(x) /= expected_size) STOP 6
60 end
62 subroutine cdim0(x, expected_size)
63 class(*) :: x
64 integer, value :: expected_size
65 if (sizeof(x) /= expected_size) STOP 7
66 if (storage_size(x)/8 /= expected_size) STOP 8
67 end
69 subroutine cdim1(x, expected_size)
70 class(*), dimension(:) :: x
71 integer, value :: expected_size
72 if (sizeof(x) /= expected_size) STOP 9
73 if (storage_size(x)/8*size(x) /= expected_size) STOP 10
74 end
76 subroutine cdimd(x, expected_size)
77 class(*), dimension(..) :: x
78 integer, value :: expected_size
79 if (sizeof(x) /= expected_size) STOP 11
80 if (storage_size(x)/8*size(x) /= expected_size) STOP 12
81 end
83 subroutine tdim1(x, expected_size)
84 type(*), dimension(:) :: x
85 integer, value :: expected_size
86 if (sizeof(x) /= expected_size) STOP 13
87 end
89 subroutine tdimd(x, expected_size)
90 type(*), dimension(..) :: x
91 integer, value :: expected_size
92 if (sizeof(x) /= expected_size) STOP 14
93 end
95 end