2020-05-12 02:38:53 +08:00
|
|
|
! RUN: %S/test_errors.sh %s %t %f18
|
2019-09-18 06:21:20 +08:00
|
|
|
! Test specification expressions
|
|
|
|
|
|
|
|
module m
|
|
|
|
type :: t(n)
|
2019-09-18 08:08:32 +08:00
|
|
|
integer, len :: n = 1
|
2019-09-18 06:21:20 +08:00
|
|
|
character(len=n) :: c
|
|
|
|
end type
|
|
|
|
interface
|
|
|
|
integer function foo()
|
|
|
|
end function
|
2019-11-13 07:43:09 +08:00
|
|
|
pure real function realfunc(x)
|
2019-09-18 08:08:32 +08:00
|
|
|
real, intent(in) :: x
|
|
|
|
end function
|
2019-11-08 08:01:38 +08:00
|
|
|
pure integer function hasProcArg(p)
|
|
|
|
import realfunc
|
|
|
|
procedure(realfunc) :: p
|
|
|
|
end function
|
2019-09-18 06:21:20 +08:00
|
|
|
end interface
|
|
|
|
integer :: coarray[*]
|
|
|
|
contains
|
2019-09-21 05:28:15 +08:00
|
|
|
pure integer function modulefunc1(n)
|
2019-09-19 06:43:12 +08:00
|
|
|
integer, value :: n
|
2019-09-21 05:28:15 +08:00
|
|
|
modulefunc1 = n
|
2019-09-19 06:43:12 +08:00
|
|
|
end function
|
2019-09-18 06:21:20 +08:00
|
|
|
subroutine test(out, optional)
|
2019-09-17 07:58:13 +08:00
|
|
|
!ERROR: Invalid specification expression: reference to impure function 'foo'
|
2019-09-18 06:21:20 +08:00
|
|
|
type(t(foo())) :: x1
|
|
|
|
integer :: local
|
2019-09-17 07:58:13 +08:00
|
|
|
!ERROR: Invalid specification expression: reference to local entity 'local'
|
2019-09-18 06:21:20 +08:00
|
|
|
type(t(local)) :: x2
|
2020-03-14 03:19:44 +08:00
|
|
|
!ERROR: The internal function 'internal' may not be referenced in a specification expression
|
2019-09-18 06:21:20 +08:00
|
|
|
type(t(internal(0))) :: x3
|
|
|
|
integer, intent(out) :: out
|
2019-09-17 07:58:13 +08:00
|
|
|
!ERROR: Invalid specification expression: reference to INTENT(OUT) dummy argument 'out'
|
2019-09-18 06:21:20 +08:00
|
|
|
type(t(out)) :: x4
|
|
|
|
integer, intent(in), optional :: optional
|
2019-09-17 07:58:13 +08:00
|
|
|
!ERROR: Invalid specification expression: reference to OPTIONAL dummy argument 'optional'
|
2019-09-18 06:21:20 +08:00
|
|
|
type(t(optional)) :: x5
|
2019-09-17 07:58:13 +08:00
|
|
|
!ERROR: Invalid specification expression: dummy procedure argument
|
2019-09-18 08:08:32 +08:00
|
|
|
type(t(hasProcArg(realfunc))) :: x6
|
2019-09-17 07:58:13 +08:00
|
|
|
!ERROR: Invalid specification expression: coindexed reference
|
2019-09-18 06:21:20 +08:00
|
|
|
type(t(coarray[1])) :: x7
|
|
|
|
type(t(kind(foo()))) :: x101 ! ok
|
2019-09-21 05:28:15 +08:00
|
|
|
type(t(modulefunc1(0))) :: x102 ! ok
|
|
|
|
type(t(modulefunc2(0))) :: x103 ! ok
|
2019-09-18 06:21:20 +08:00
|
|
|
contains
|
|
|
|
pure integer function internal(n)
|
|
|
|
integer, value :: n
|
|
|
|
internal = n
|
|
|
|
end function
|
|
|
|
end subroutine
|
2019-09-21 05:28:15 +08:00
|
|
|
pure integer function modulefunc2(n)
|
|
|
|
integer, value :: n
|
|
|
|
modulefunc2 = n
|
|
|
|
end function
|
2019-09-18 06:21:20 +08:00
|
|
|
end module
|