1! { dg-do run }
2!
3! PR fortran/61881
4! PR fortran/61888
5!
6!
7use iso_c_binding
8implicit none
9
10call dim0(5, 4)
11
12call dim1([1, 2, 3], 4*3)
13
14call dimd(5, 4)
15call dimd([1, 2, 3], 4*3)
16call dimd(reshape([1, 4, 2, 3],[2, 2]), 4*4)
17
18call tdim1([1, 2, 3], 4*3)
19call tdim1([1_8, 2_8, 3_8], 8*3)
20
21call tdimd(5, 4)
22call tdimd([1, 2, 3], 4*3)
23call tdimd(reshape([1, 4, 2, 3], [2, 2]), 4*4)
24call tdimd(5_8, 8)
25call tdimd([1_8, 2_8, 3_8], 8*3)
26call tdimd(reshape([1_8, 4_8, 2_8, 3_8],[2,2]), 8*4)
27
28call cdim0(5, 4)
29
30call cdim1([1, 2, 3], 4*3)
31
32call cdimd(5, 4)
33call cdimd([1, 2, 3], 4*3)
34call cdimd(reshape([1,4,2,3],[2,2]), 4*4)
35call cdimd(5_8, 8)
36call cdimd([1_8, 2_8, 3_8], 8*3)
37call cdimd(reshape([1_8, 4_8, 2_8, 3_8], [2, 2]), 8*4)
38
39contains
40
41subroutine 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
46end
47
48subroutine 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
53end
54
55subroutine 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
60end
61
62subroutine 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
67end
68
69subroutine 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
74end
75
76subroutine 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
81end
82
83subroutine tdim1(x, expected_size)
84  type(*), dimension(:) :: x
85  integer, value :: expected_size
86  if (sizeof(x) /= expected_size) STOP 13
87end
88
89subroutine tdimd(x, expected_size)
90  type(*), dimension(..) :: x
91  integer, value :: expected_size
92  if (sizeof(x) /= expected_size) STOP 14
93end
94
95end
96