2020-05-12 02:38:53 +08:00
! RUN: %S/test_errors.sh %s %t %f18
2019-09-05 04:26:41 +08:00
! Test 15.5.2.4 constraints and restrictions for non-POINTER non-ALLOCATABLE
! dummy arguments.
module m01
type :: t
end type
type :: pdt ( n )
integer , len :: n
end type
type :: tbp
contains
procedure :: binding = > subr01
end type
type :: final
contains
final :: subr02
end type
type :: alloc
real , allocatable :: a ( : )
end type
type :: ultimateCoarray
2019-10-30 03:46:25 +08:00
real , allocatable :: a [ : ]
2019-09-05 04:26:41 +08:00
end type
contains
subroutine subr01 ( this )
class ( tbp ) , intent ( in ) :: this
end subroutine
subroutine subr02 ( this )
2020-10-01 04:34:23 +08:00
type ( final ) , intent ( inout ) :: this
2019-09-05 04:26:41 +08:00
end subroutine
subroutine poly ( x )
class ( t ) , intent ( in ) :: x
end subroutine
2019-10-09 06:21:09 +08:00
subroutine polyassumedsize ( x )
class ( t ) , intent ( in ) :: x ( * )
end subroutine
2019-09-05 04:26:41 +08:00
subroutine assumedsize ( x )
real :: x ( * )
end subroutine
subroutine assumedrank ( x )
real :: x ( . . )
end subroutine
subroutine assumedtypeandsize ( x )
type ( * ) :: x ( * )
end subroutine
subroutine assumedshape ( x )
real :: x ( : )
end subroutine
subroutine contiguous ( x )
real , contiguous :: x ( : )
end subroutine
subroutine intentout ( x )
real , intent ( out ) :: x
end subroutine
subroutine intentinout ( x )
real , intent ( in out ) :: x
end subroutine
subroutine asynchronous ( x )
real , asynchronous :: x
end subroutine
subroutine asynchronousValue ( x )
real , asynchronous , value :: x
end subroutine
subroutine volatile ( x )
real , volatile :: x
end subroutine
subroutine pointer ( x )
real , pointer :: x ( : )
end subroutine
subroutine valueassumedsize ( x )
2019-10-30 03:46:25 +08:00
real , intent ( in ) :: x ( * )
2019-09-05 04:26:41 +08:00
end subroutine
2019-10-11 07:06:05 +08:00
subroutine volatileassumedsize ( x )
real , volatile :: x ( * )
end subroutine
subroutine volatilecontiguous ( x )
real , volatile :: x ( * )
end subroutine
2019-09-05 04:26:41 +08:00
subroutine test01 ( x ) ! 15.5.2.4(2)
class ( t ) , intent ( in ) :: x [ * ]
2019-10-17 02:53:03 +08:00
!ERROR: Coindexed polymorphic object may not be associated with a polymorphic dummy argument 'x='
2019-09-05 04:26:41 +08:00
call poly ( x [ 1 ] )
end subroutine
subroutine mono ( x )
type ( t ) , intent ( in ) :: x
end subroutine
subroutine test02 ( x ) ! 15.5.2.4(2)
class ( t ) , intent ( in ) :: x ( * )
2019-10-17 02:53:03 +08:00
!ERROR: Assumed-size polymorphic array may not be associated with a monomorphic dummy argument 'x='
2019-09-05 04:26:41 +08:00
call mono ( x )
end subroutine
subroutine typestar ( x )
type ( * ) , intent ( in ) :: x
end subroutine
subroutine test03 ! 15.5.2.4(2)
type ( pdt ( 0 ) ) :: x
2019-10-17 02:53:03 +08:00
!ERROR: Actual argument associated with TYPE(*) dummy argument 'x=' may not have a parameterized derived type
2019-09-05 04:26:41 +08:00
call typestar ( x )
end subroutine
subroutine test04 ! 15.5.2.4(2)
type ( tbp ) :: x
2019-10-18 06:29:26 +08:00
!ERROR: Actual argument associated with TYPE(*) dummy argument 'x=' may not have type-bound procedure 'binding'
2019-09-05 04:26:41 +08:00
call typestar ( x )
end subroutine
subroutine test05 ! 15.5.2.4(2)
type ( final ) :: x
2020-10-01 04:34:23 +08:00
!ERROR: Actual argument associated with TYPE(*) dummy argument 'x=' may not have derived type 'final' with FINAL subroutine 'subr02'
2019-09-05 04:26:41 +08:00
call typestar ( x )
end subroutine
subroutine ch2 ( x )
2019-10-17 06:36:54 +08:00
character ( 2 ) , intent ( in out ) :: x
2019-09-05 04:26:41 +08:00
end subroutine
subroutine test06 ! 15.5.2.4(4)
character :: ch1
2019-10-17 06:36:54 +08:00
! The actual argument is converted to a padded expression.
!ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'x=' must be definable
2019-09-05 04:26:41 +08:00
call ch2 ( ch1 )
end subroutine
subroutine out01 ( x )
type ( alloc ) :: x
end subroutine
subroutine test07 ( x ) ! 15.5.2.4(6)
type ( alloc ) :: x [ * ]
2019-10-18 06:29:26 +08:00
!ERROR: Coindexed actual argument with ALLOCATABLE ultimate component '%a' must be associated with a dummy argument 'x=' with VALUE or INTENT(IN) attributes
2019-09-05 04:26:41 +08:00
call out01 ( x [ 1 ] )
end subroutine
subroutine test08 ( x ) ! 15.5.2.4(13)
2019-10-09 06:21:09 +08:00
real :: x ( 1 ) [ * ]
2019-10-17 02:53:03 +08:00
!ERROR: Coindexed scalar actual argument must be associated with a scalar dummy argument 'x='
2019-10-09 06:21:09 +08:00
call assumedsize ( x ( 1 ) [ 1 ] )
2019-09-05 04:26:41 +08:00
end subroutine
subroutine charray ( x )
character :: x ( 10 )
end subroutine
subroutine test09 ( ashape , polyarray , c ) ! 15.5.2.4(14), 15.5.2.11
real :: x , arr ( 10 )
real , pointer :: p ( : )
real :: ashape ( : )
class ( t ) :: polyarray ( * )
character ( 10 ) :: c ( : )
2019-10-17 02:53:03 +08:00
!ERROR: Whole scalar actual argument may not be associated with a dummy argument 'x=' array
2019-09-05 04:26:41 +08:00
call assumedsize ( x )
2019-10-18 01:57:01 +08:00
!ERROR: Scalar POINTER target may not be associated with a dummy argument 'x=' array
2019-09-05 04:26:41 +08:00
call assumedsize ( p ( 1 ) )
2019-10-17 02:53:03 +08:00
!ERROR: Element of assumed-shape array may not be associated with a dummy argument 'x=' array
2019-09-05 04:26:41 +08:00
call assumedsize ( ashape ( 1 ) )
2019-10-18 01:57:01 +08:00
!ERROR: Polymorphic scalar may not be associated with a dummy argument 'x=' array
2019-10-09 06:21:09 +08:00
call polyassumedsize ( polyarray ( 1 ) )
2019-09-05 04:26:41 +08:00
call charray ( c ( 1 : 1 ) ) ! not an error if character
call assumedsize ( arr ( 1 ) ) ! not an error if element in sequence
call assumedrank ( x ) ! not an error
call assumedtypeandsize ( x ) ! not an error
end subroutine
subroutine test10 ( a ) ! 15.5.2.4(16)
2019-10-09 06:21:09 +08:00
real :: scalar , matrix ( 2 , 3 )
2019-09-05 04:26:41 +08:00
real :: a ( * )
2019-10-17 02:53:03 +08:00
!ERROR: Scalar actual argument may not be associated with assumed-shape dummy argument 'x='
2019-09-05 04:26:41 +08:00
call assumedshape ( scalar )
2019-10-11 07:06:05 +08:00
!ERROR: Rank of dummy argument is 1, but actual argument has rank 2
2019-09-05 04:26:41 +08:00
call assumedshape ( matrix )
2019-10-17 02:53:03 +08:00
!ERROR: Assumed-size array may not be associated with assumed-shape dummy argument 'x='
2019-10-09 06:21:09 +08:00
call assumedshape ( a )
2019-09-05 04:26:41 +08:00
end subroutine
subroutine test11 ( in ) ! C15.5.2.4(20)
real , intent ( in ) :: in
2019-09-05 07:20:34 +08:00
real :: x
2019-10-09 06:21:09 +08:00
x = 0.
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with INTENT(OUT) dummy argument 'x=' must be definable
2019-09-05 04:26:41 +08:00
call intentout ( in )
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with INTENT(OUT) dummy argument 'x=' must be definable
2019-09-05 04:26:41 +08:00
call intentout ( 3.14159 )
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with INTENT(OUT) dummy argument 'x=' must be definable
2019-09-05 04:26:41 +08:00
call intentout ( in + 1. )
2019-10-09 06:21:09 +08:00
call intentout ( x ) ! ok
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with INTENT(OUT) dummy argument 'x=' must be definable
2019-10-09 06:21:09 +08:00
call intentout ( ( x ) )
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'x=' must be definable
2019-09-05 04:26:41 +08:00
call intentinout ( in )
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'x=' must be definable
2019-09-05 04:26:41 +08:00
call intentinout ( 3.14159 )
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'x=' must be definable
2019-09-05 04:26:41 +08:00
call intentinout ( in + 1. )
2019-09-05 07:20:34 +08:00
call intentinout ( x ) ! ok
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'x=' must be definable
2019-09-05 07:20:34 +08:00
call intentinout ( ( x ) )
2019-09-05 04:26:41 +08:00
end subroutine
subroutine test12 ! 15.5.2.4(21)
real :: a ( 1 )
integer :: j ( 1 )
j ( 1 ) = 1
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with INTENT(OUT) dummy argument 'x=' must be definable
2019-09-05 04:26:41 +08:00
call intentout ( a ( j ) )
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'x=' must be definable
2019-09-05 04:26:41 +08:00
call intentinout ( a ( j ) )
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with ASYNCHRONOUS dummy argument 'x=' must be definable
2019-09-05 04:26:41 +08:00
call asynchronous ( a ( j ) )
2019-10-17 06:36:54 +08:00
!ERROR: Actual argument associated with VOLATILE dummy argument 'x=' must be definable
2019-09-05 04:26:41 +08:00
call volatile ( a ( j ) )
end subroutine
subroutine coarr ( x )
type ( ultimateCoarray ) :: x
end subroutine
subroutine volcoarr ( x )
type ( ultimateCoarray ) , volatile :: x
end subroutine
subroutine test13 ( a , b ) ! 15.5.2.4(22)
type ( ultimateCoarray ) :: a
type ( ultimateCoarray ) , volatile :: b
call coarr ( a ) ! ok
call volcoarr ( b ) ! ok
2019-10-18 06:29:26 +08:00
!ERROR: VOLATILE attribute must match for dummy argument 'x=' when actual argument has a coarray ultimate component '%a'
2019-09-05 04:26:41 +08:00
call coarr ( b )
2019-10-18 06:29:26 +08:00
!ERROR: VOLATILE attribute must match for dummy argument 'x=' when actual argument has a coarray ultimate component '%a'
2019-09-05 04:26:41 +08:00
call volcoarr ( a )
end subroutine
subroutine test14 ( a , b , c , d ) ! C1538
real :: a [ * ]
real , asynchronous :: b [ * ]
real , volatile :: c [ * ]
real , asynchronous , volatile :: d [ * ]
call asynchronous ( a [ 1 ] ) ! ok
call volatile ( a [ 1 ] ) ! ok
call asynchronousValue ( b [ 1 ] ) ! ok
call asynchronousValue ( c [ 1 ] ) ! ok
call asynchronousValue ( d [ 1 ] ) ! ok
2019-10-17 02:53:03 +08:00
!ERROR: Coindexed ASYNCHRONOUS or VOLATILE actual argument may not be associated with dummy argument 'x=' with ASYNCHRONOUS or VOLATILE attributes unless VALUE
2019-09-05 04:26:41 +08:00
call asynchronous ( b [ 1 ] )
2019-10-17 02:53:03 +08:00
!ERROR: Coindexed ASYNCHRONOUS or VOLATILE actual argument may not be associated with dummy argument 'x=' with ASYNCHRONOUS or VOLATILE attributes unless VALUE
2019-09-05 04:26:41 +08:00
call volatile ( b [ 1 ] )
2019-10-17 02:53:03 +08:00
!ERROR: Coindexed ASYNCHRONOUS or VOLATILE actual argument may not be associated with dummy argument 'x=' with ASYNCHRONOUS or VOLATILE attributes unless VALUE
2019-09-05 04:26:41 +08:00
call asynchronous ( c [ 1 ] )
2019-10-17 02:53:03 +08:00
!ERROR: Coindexed ASYNCHRONOUS or VOLATILE actual argument may not be associated with dummy argument 'x=' with ASYNCHRONOUS or VOLATILE attributes unless VALUE
2019-09-05 04:26:41 +08:00
call volatile ( c [ 1 ] )
2019-10-17 02:53:03 +08:00
!ERROR: Coindexed ASYNCHRONOUS or VOLATILE actual argument may not be associated with dummy argument 'x=' with ASYNCHRONOUS or VOLATILE attributes unless VALUE
2019-09-05 04:26:41 +08:00
call asynchronous ( d [ 1 ] )
2019-10-17 02:53:03 +08:00
!ERROR: Coindexed ASYNCHRONOUS or VOLATILE actual argument may not be associated with dummy argument 'x=' with ASYNCHRONOUS or VOLATILE attributes unless VALUE
2019-09-05 04:26:41 +08:00
call volatile ( d [ 1 ] )
end subroutine
subroutine test15 ( ) ! C1539
2019-09-10 01:43:19 +08:00
real , pointer :: a ( : )
2019-09-05 04:26:41 +08:00
real , asynchronous :: b ( 10 )
real , volatile :: c ( 10 )
real , asynchronous , volatile :: d ( 10 )
call assumedsize ( a ( :: 2 ) ) ! ok
call contiguous ( a ( :: 2 ) ) ! ok
call valueassumedsize ( a ( :: 2 ) ) ! ok
call valueassumedsize ( b ( :: 2 ) ) ! ok
call valueassumedsize ( c ( :: 2 ) ) ! ok
call valueassumedsize ( d ( :: 2 ) ) ! ok
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatileassumedsize ( b ( :: 2 ) )
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatilecontiguous ( b ( :: 2 ) )
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatileassumedsize ( c ( :: 2 ) )
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatilecontiguous ( c ( :: 2 ) )
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatileassumedsize ( d ( :: 2 ) )
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatilecontiguous ( d ( :: 2 ) )
2019-09-05 04:26:41 +08:00
end subroutine
subroutine test16 ( ) ! C1540
real , pointer :: a ( : )
real , asynchronous , pointer :: b ( : )
real , volatile , pointer :: c ( : )
real , asynchronous , volatile , pointer :: d ( : )
call assumedsize ( a ) ! ok
call contiguous ( a ) ! ok
call pointer ( a ) ! ok
call pointer ( b ) ! ok
call pointer ( c ) ! ok
call pointer ( d ) ! ok
call valueassumedsize ( a ) ! ok
call valueassumedsize ( b ) ! ok
call valueassumedsize ( c ) ! ok
call valueassumedsize ( d ) ! ok
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatileassumedsize ( b )
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatilecontiguous ( b )
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatileassumedsize ( c )
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatilecontiguous ( c )
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatileassumedsize ( d )
2019-10-17 02:53:03 +08:00
!ERROR: ASYNCHRONOUS or VOLATILE actual argument that is not simply contiguous may not be associated with a contiguous dummy argument 'x='
2019-10-11 07:06:05 +08:00
call volatilecontiguous ( d )
2019-09-05 04:26:41 +08:00
end subroutine
end module