1! { dg-do compile} 2! { dg-additional-options "-fcoarray=single" } 3! 4! TS 29113 5! C535b An assumed-rank variable name shall not appear in a designator 6! or expression except as an actual argument corresponding to a dummy 7! argument that is assumed-rank, the argument of the C_LOC function 8! in the ISO_C_BINDING intrinsic module, or the first argument in a 9! reference to an intrinsic inquiry function. 10! 11! This has been renamed C838 in the Fortran 2018 standard, with C_SIZEOF 12! and SELECT_RANK additionally added. 13! 14! This test file contains tests that are expected to all pass. 15 16! Check that passing an assumed-rank variable as an actual argument 17! corresponding to an assumed-rank dummy works. 18 19module m 20 interface 21 subroutine g (a, b) 22 implicit none 23 real :: a(..) 24 integer :: b 25 end subroutine 26 end interface 27end module 28 29subroutine s0 (x) 30 use m 31 implicit none 32 real :: x(..) 33 34 call g (x, 1) 35end subroutine 36 37! Check that calls to the permitted intrinsic functions work. 38 39function test_c_loc (a) 40 use iso_c_binding 41 implicit none 42 integer, target :: a(..) 43 type(c_ptr) :: test_c_loc 44 45 test_c_loc = c_loc (a) 46end function 47 48function test_allocated (a) 49 implicit none 50 integer, allocatable :: a(..) 51 logical :: test_allocated 52 53 test_allocated = allocated (a) 54end function 55 56! 2-argument forms of the associated intrinsic are tested in c535b-3.f90. 57function test_associated (a) 58 implicit none 59 integer, pointer :: a(..) 60 logical :: test_associated 61 62 test_associated = associated (a) 63end function 64 65function test_bit_size (a) 66 implicit none 67 integer :: a(..) 68 integer :: test_bit_size 69 70 test_bit_size = bit_size (a) 71end function 72 73function test_digits (a) 74 implicit none 75 integer :: a(..) 76 integer :: test_digits 77 78 test_digits = digits (a) 79end function 80 81function test_epsilon (a) 82 implicit none 83 real :: a(..) 84 real :: test_epsilon 85 86 test_epsilon = epsilon (a) 87end function 88 89function test_huge (a) 90 implicit none 91 integer :: a(..) 92 integer :: test_huge 93 94 test_huge = huge (a) 95end function 96 97function test_is_contiguous (a) 98 implicit none 99 integer :: a(..) 100 logical :: test_is_contiguous 101 102 test_is_contiguous = is_contiguous (a) 103end function 104 105function test_kind (a) 106 implicit none 107 integer :: a(..) 108 integer :: test_kind 109 110 test_kind = kind (a) 111end function 112 113function test_lbound (a) 114 implicit none 115 integer :: a(..) 116 integer :: test_lbound 117 118 test_lbound = lbound (a, 1) 119end function 120 121function test_len1 (a) 122 implicit none 123 character(len=5) :: a(..) 124 integer :: test_len1 125 126 test_len1 = len (a) 127end function 128 129function test_len2 (a) 130 implicit none 131 character(len=*) :: a(..) 132 integer :: test_len2 133 134 test_len2 = len (a) 135end function 136 137function test_len3 (a) 138 implicit none 139 character(len=5), pointer :: a(..) 140 integer :: test_len3 141 142 test_len3 = len (a) 143end function 144 145function test_len4 (a) 146 implicit none 147 character(len=*), pointer :: a(..) 148 integer :: test_len4 149 150 test_len4 = len (a) 151end function 152 153function test_len5 (a) 154 implicit none 155 character(len=:), pointer :: a(..) 156 integer :: test_len5 157 158 test_len5 = len (a) 159end function 160 161function test_len6 (a) 162 implicit none 163 character(len=5), allocatable :: a(..) 164 integer :: test_len6 165 166 test_len6 = len (a) 167end function 168 169function test_len7 (a) 170 implicit none 171 character(len=*), allocatable :: a(..) 172 integer :: test_len7 173 174 test_len7 = len (a) 175end function 176 177function test_len8 (a) 178 implicit none 179 character(len=:), allocatable :: a(..) 180 integer :: test_len8 181 182 test_len8 = len (a) 183end function 184 185function test_maxexponent (a) 186 implicit none 187 real :: a(..) 188 integer :: test_maxexponent 189 190 test_maxexponent = maxexponent (a) 191end function 192 193function test_minexponent (a) 194 implicit none 195 real :: a(..) 196 integer :: test_minexponent 197 198 test_minexponent = minexponent (a) 199end function 200 201function test_new_line (a) 202 implicit none 203 character :: a(..) 204 character :: test_new_line 205 206 test_new_line = new_line (a) 207end function 208 209function test_precision (a) 210 implicit none 211 real :: a(..) 212 integer :: test_precision 213 214 test_precision = precision (a) 215end function 216 217function test_present (a, b, c) 218 implicit none 219 integer :: a, b 220 integer, optional :: c(..) 221 integer :: test_present 222 223 if (present (c)) then 224 test_present = a 225 else 226 test_present = b 227 end if 228end function 229 230function test_radix (a) 231 implicit none 232 real :: a(..) 233 integer :: test_radix 234 235 test_radix = radix (a) 236end function 237 238function test_range (a) 239 implicit none 240 real :: a(..) 241 integer :: test_range 242 243 test_range = range (a) 244end function 245 246function test_rank (a) 247 implicit none 248 integer :: a(..) 249 integer :: test_rank 250 251 test_rank = rank (a) 252end function 253 254function test_shape (a) 255 implicit none 256 integer :: a(..) 257 logical :: test_shape 258 259 test_shape = (rank (a) .eq. size (shape (a))) 260end function 261 262function test_size (a) 263 implicit none 264 integer :: a(..) 265 logical :: test_size 266 267 test_size = (size (a) .eq. product (shape (a))) 268end function 269 270function test_storage_size (a) 271 implicit none 272 integer :: a(..) 273 integer :: test_storage_size 274 275 test_storage_size = storage_size (a) 276end function 277 278function test_tiny (a) 279 implicit none 280 real :: a(..) 281 real :: test_tiny 282 283 test_tiny = tiny (a) 284end function 285 286function test_ubound (a) 287 implicit none 288 integer :: a(..) 289 integer :: test_ubound 290 291 test_ubound = ubound (a, 1) 292end function 293 294! Note: there are no tests for these inquiry functions that can't 295! take an assumed-rank array argument for other reasons: 296! 297! coshape, lcobound, ucobound: requires CODIMENSION attribute, which is 298! not permitted on an assumed-rank variable. 299! 300 301! F2018 additionally permits the first arg to C_SIZEOF to be 302! assumed-rank (C838). 303 304function test_c_sizeof (a) 305 use iso_c_binding 306 implicit none 307 integer :: a(..) 308 integer :: test_c_sizeof 309 310 test_c_sizeof = c_sizeof (a) 311end function 312 313! F2018 additionally permits an assumed-rank array as the selector 314! in a SELECT RANK construct (C838). 315 316function test_select_rank (a) 317 implicit none 318 integer :: a(..) 319 integer :: test_select_rank 320 321 select rank (a) 322 rank (0) 323 test_select_rank = 0 324 rank (1) 325 test_select_rank = 1 326 rank (2) 327 test_select_rank = 2 328 rank default 329 test_select_rank = -1 330 end select 331end function 332