| 1 |
! { dg-do compile } |
| 2 |
! { dg-options "-std=f2023 -Wsurprising" } |
| 3 |
! |
| 4 |
! Test Reinhold Bader's F202y proposal (J3 DIN4) "Generic processing of assumed |
| 5 |
! rank objects". The present gfortran implementation includes pointer assignment |
| 6 |
! and ASSOCIATE, with rank remapping of the var or associate-name, and RESHAPE. |
| 7 |
! J3 document 24-136r1.txt, by Malcolm Cohen, considers further possibilities. |
| 8 |
! |
| 9 |
! Contributed by Paul Thomas <[email protected]> |
| 10 |
! |
| 11 |
real :: x(2,2,2) |
| 12 |
real, parameter :: xp(*) = [1,2,3,4,5,6,7,8] |
| 13 |
x = reshape (xp, [2,2,2]) |
| 14 |
call my_sub (x) |
| 15 |
if (any (reshape (x, [8]) .ne. xp(8:1:-1))) stop 1 |
| 16 |
call my_assumed_size_target (x) |
| 17 |
contains |
| 18 |
subroutine my_sub (arg) |
| 19 |
real, target, contiguous :: arg(..) |
| 20 |
real, allocatable :: y(:) |
| 21 |
real, pointer :: argp(:,:) |
| 22 |
integer :: i |
| 23 |
|
| 24 |
if (size (arg) .lt. 0) return |
| 25 |
|
| 26 |
if (size (arg) .ne. 8) stop 10 |
| 27 |
|
| 28 |
! Check reshape |
| 29 |
y = reshape (arg, [size (arg)]) ! { dg-error "experimental F202y feature" } |
| 30 |
if (any (y .ne. xp)) stop 20 |
| 31 |
|
| 32 |
! Check pointer assignment |
| 33 |
argp(1:2,1: size(arg)/2) => arg ! { dg-error "experimental F202y feature" } |
| 34 |
if (size (argp) .ne. size (x)) stop 30 |
| 35 |
if (any ((argp) .ne. reshape (x, [2, size (x)/2]))) stop 31 |
| 36 |
|
| 37 |
! Check ASSOCIATE |
| 38 |
i = size (arg) |
| 39 |
associate (a(1:2,1:i/2) => arg) ! { dg-error "experimental F202y feature" } |
| 40 |
if (any (a .ne. argp)) stop 40 |
| 41 |
end associate |
| 42 |
|
| 43 |
associate (a(1:size(arg)) => arg) ! { dg-error "experimental F202y feature" } |
| 44 |
if (any (a .ne. xp)) stop 41 |
| 45 |
a = a(8:1:-1) |
| 46 |
end associate |
| 47 |
end |
| 48 |
|
| 49 |
subroutine my_assumed_size_target (arg) |
| 50 |
real :: arg(2, 2, *) |
| 51 |
call my_sub (arg) ! { dg-warning "to an assumed-rank dummy" } |
| 52 |
end |
| 53 |
end |