2020-05-12 02:38:53 +08:00
! RUN: %S/test_errors.sh %s %t %f18
2019-09-05 06:08:53 +08:00
! Test 15.5.2.5 constraints and restrictions for POINTER & ALLOCATABLE
! arguments when both sides of the call have the same attributes.
module m
type :: t
end type
type , extends ( t ) :: t2
end type
type :: pdt ( n )
integer , len :: n
end type
type ( t ) , pointer :: mp ( : ) , mpmat ( : , : )
type ( t ) , allocatable :: ma ( : ) , mamat ( : , : )
class ( t ) , pointer :: pp ( : )
class ( t ) , allocatable :: pa ( : )
class ( t2 ) , pointer :: pp2 ( : )
class ( t2 ) , allocatable :: pa2 ( : )
class ( * ) , pointer :: up ( : )
class ( * ) , allocatable :: ua ( : )
2020-02-27 12:19:48 +08:00
!ERROR: An assumed (*) type parameter may be used only for a (non-statement function) dummy argument, associate name, named constant, or external function result
2019-10-25 07:08:06 +08:00
type ( pdt ( * ) ) , pointer :: amp ( : )
2020-02-27 12:19:48 +08:00
!ERROR: An assumed (*) type parameter may be used only for a (non-statement function) dummy argument, associate name, named constant, or external function result
2019-10-25 07:08:06 +08:00
type ( pdt ( * ) ) , allocatable :: ama ( : )
type ( pdt ( : ) ) , pointer :: dmp ( : )
type ( pdt ( : ) ) , allocatable :: dma ( : )
2019-09-05 06:08:53 +08:00
type ( pdt ( 1 ) ) , pointer :: nmp ( : )
type ( pdt ( 1 ) ) , allocatable :: nma ( : )
contains
subroutine smp ( x )
type ( t ) , pointer :: x ( : )
end subroutine
subroutine sma ( x )
type ( t ) , allocatable :: x ( : )
end subroutine
subroutine spp ( x )
class ( t ) , pointer :: x ( : )
end subroutine
subroutine spa ( x )
class ( t ) , allocatable :: x ( : )
end subroutine
subroutine sup ( x )
class ( * ) , pointer :: x ( : )
end subroutine
subroutine sua ( x )
class ( * ) , allocatable :: x ( : )
end subroutine
2019-10-25 07:08:06 +08:00
subroutine samp ( x )
2019-09-05 06:08:53 +08:00
type ( pdt ( * ) ) , pointer :: x ( : )
end subroutine
2019-10-25 07:08:06 +08:00
subroutine sama ( x )
type ( pdt ( * ) ) , allocatable :: x ( : )
end subroutine
subroutine sdmp ( x )
type ( pdt ( : ) ) , pointer :: x ( : )
end subroutine
2019-09-05 06:08:53 +08:00
subroutine sdma ( x )
2019-10-25 07:08:06 +08:00
type ( pdt ( : ) ) , allocatable :: x ( : )
2019-09-05 06:08:53 +08:00
end subroutine
subroutine snmp ( x )
type ( pdt ( 1 ) ) , pointer :: x ( : )
end subroutine
subroutine snma ( x )
2019-10-25 07:08:06 +08:00
type ( pdt ( 1 ) ) , allocatable :: x ( : )
2019-09-05 06:08:53 +08:00
end subroutine
subroutine test
call smp ( mp ) ! ok
call sma ( ma ) ! ok
call spp ( pp ) ! ok
call spa ( pa ) ! ok
2019-10-25 07:08:06 +08:00
!ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is polymorphic, both must be so
2019-09-05 06:08:53 +08:00
call smp ( pp )
2019-10-25 07:08:06 +08:00
!ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is polymorphic, both must be so
call sma ( pa )
!ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is polymorphic, both must be so
2019-09-05 06:08:53 +08:00
call spp ( mp )
2019-10-25 07:08:06 +08:00
!ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is polymorphic, both must be so
call spa ( ma )
!ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is unlimited polymorphic, both must be so
2019-09-05 06:08:53 +08:00
call sup ( pp )
2019-10-25 07:08:06 +08:00
!ERROR: If a POINTER or ALLOCATABLE dummy or actual argument is unlimited polymorphic, both must be so
2019-09-05 06:08:53 +08:00
call sua ( pa )
2019-12-21 05:03:30 +08:00
!ERROR: Actual argument type 'CLASS(*)' is not compatible with dummy argument type 't'
2019-09-05 06:08:53 +08:00
call spp ( up )
2019-12-21 05:03:30 +08:00
!ERROR: Actual argument type 'CLASS(*)' is not compatible with dummy argument type 't'
2019-09-05 06:08:53 +08:00
call spa ( ua )
2019-10-25 07:08:06 +08:00
!ERROR: POINTER or ALLOCATABLE dummy and actual arguments must have the same declared type
2019-09-05 06:08:53 +08:00
call spp ( pp2 )
2019-10-25 07:08:06 +08:00
!ERROR: POINTER or ALLOCATABLE dummy and actual arguments must have the same declared type
2019-09-05 06:08:53 +08:00
call spa ( pa2 )
2019-10-25 07:08:06 +08:00
!ERROR: Rank of dummy argument is 1, but actual argument has rank 2
2019-09-05 06:08:53 +08:00
call smp ( mpmat )
2019-10-25 07:08:06 +08:00
!ERROR: Rank of dummy argument is 1, but actual argument has rank 2
2019-09-05 06:08:53 +08:00
call sma ( mamat )
call sdmp ( dmp ) ! ok
call sdma ( dma ) ! ok
call snmp ( nmp ) ! ok
call snma ( nma ) ! ok
2019-10-25 07:08:06 +08:00
call samp ( nmp ) ! ok
call sama ( nma ) ! ok
!ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
2019-09-05 06:08:53 +08:00
call sdmp ( nmp )
2019-10-25 07:08:06 +08:00
!ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
2019-09-05 06:08:53 +08:00
call sdma ( nma )
2019-10-25 07:08:06 +08:00
!ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
2019-09-05 06:08:53 +08:00
call snmp ( dmp )
2019-10-25 07:08:06 +08:00
!ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
2019-09-05 06:08:53 +08:00
call snma ( dma )
2019-10-25 07:08:06 +08:00
!ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
call samp ( dmp )
!ERROR: Dummy and actual arguments must defer the same type parameters when POINTER or ALLOCATABLE
call sama ( dma )
2019-09-05 06:08:53 +08:00
end subroutine
end module