1! { dg-do compile } 2! 3! PR fortran/97242 4! 5implicit none 6type t 7 integer, allocatable :: A(:,:,:) 8 integer :: D(5,5,5) 9end type t 10 11type(t), target :: B(5) 12integer, pointer, contiguous :: P(:,:,:) 13integer, target :: C(5,5,5) 14integer :: i 15 16i = 1 17 18! OK: contiguous 19P => B(i)%A 20P => B(i)%A(:,:,:) 21P => C 22P => C(:,:,:) 23call foo (B(i)%A) 24call foo (B(i)%A(:,:,:)) 25call foo (C) 26call foo (C(:,:,:)) 27 28! Invalid - not contiguous 29! "If the pointer object has the CONTIGUOUS attribute, the pointer target shall be contiguous." 30! → known to be noncontigous (not always checkable, however) 31P => B(i)%A(:,::3,::4) ! <<< Unknown as (1:2:3,1:3:4) is contiguous and has one element. 32P => B(i)%D(:,::2,::2) ! { dg-error "Assignment to contiguous pointer from non-contiguous target" } 33P => C(::2,::2,::2) ! { dg-error "Assignment to contiguous pointer from non-contiguous target" } 34 35! This following is stricter: 36! C1541 The actual argument corresponding to a dummy pointer with the 37! CONTIGUOUS attribute shall be simply contiguous (9.5.4). 38call foo (B(i)%A(:,::3,::4)) ! { dg-error "must be simply contiguous" } 39call foo (C(::2,::2,::2)) ! { dg-error "must be simply contiguous" } 40 41contains 42 subroutine foo(Q) 43 integer, pointer, intent(in), contiguous :: Q(:,:,:) 44 end subroutine foo 45end 46