Per 15.5.2.5 p2, when both a dummy data object and its associated actual argument are ALLOCATABLE or POINTER, there are rules requiring that both be unlimited polymorphic if either is, and that both be polymorphic if either is. The justifications for the first restriction is that the called procedure might change the type of an unlimited polymorphic dummy argument, but as this cannot occur for a dummy argument with INTENT(IN), we can relax the check to an optional portability warning. The justification for the second restriction is that some implementations would have to create a type descriptor to associate a monomorphic allocatable/pointer actual argument with a polymorphic dummy argument, and that doesn't apply to f18 since we use descriptors for them anyways. Relaxing these needless checks allows more library procedures to use "class(*), dimension(..), pointer, intent(in)" dummy arguments in explicit interfaces. Differential Revision: https://reviews.llvm.org/D151941
26 lines
1017 B
Fortran
26 lines
1017 B
Fortran
! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
|
|
! Test the RelaxedIntentInChecking extension
|
|
module m
|
|
contains
|
|
subroutine intentInUnlimited(x)
|
|
class(*), dimension(..), pointer, intent(in) :: x
|
|
end
|
|
subroutine intentInOutUnlimited(x)
|
|
class(*), dimension(..), pointer, intent(in out) :: x
|
|
end
|
|
subroutine test
|
|
integer, target :: scalar
|
|
real, pointer :: arrayptr(:)
|
|
class(*), pointer :: unlimited(:)
|
|
call intentInUnlimited(scalar)
|
|
!ERROR: Actual argument associated with POINTER dummy argument 'x=' must also be POINTER unless INTENT(IN)
|
|
call intentInOutUnlimited(scalar)
|
|
!PORTABILITY: If a POINTER or ALLOCATABLE dummy or actual argument is unlimited polymorphic, both should be so
|
|
call intentInUnlimited(arrayptr)
|
|
!ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is unlimited polymorphic, both must be so
|
|
call intentInOutUnlimited(arrayptr)
|
|
call intentInUnlimited(unlimited) ! ok
|
|
call intentInOutUnlimited(unlimited) ! ok
|
|
end
|
|
end
|