1! RUN: %S/test_errors.sh %s %t %f18
2! Test specification expressions
3
4module m
5  type :: t(n)
6    integer, len :: n = 1
7    character(len=n) :: c
8  end type
9  interface
10    integer function foo()
11    end function
12    pure real function realfunc(x)
13      real, intent(in) :: x
14    end function
15    pure integer function hasProcArg(p)
16      import realfunc
17      procedure(realfunc) :: p
18    end function
19  end interface
20  integer :: coarray[*]
21 contains
22  pure integer function modulefunc1(n)
23    integer, value :: n
24    modulefunc1 = n
25  end function
26  subroutine test(out, optional)
27    !ERROR: Invalid specification expression: reference to impure function 'foo'
28    type(t(foo())) :: x1
29    integer :: local
30    !ERROR: Invalid specification expression: reference to local entity 'local'
31    type(t(local)) :: x2
32    !ERROR: The internal function 'internal' may not be referenced in a specification expression
33    type(t(internal(0))) :: x3
34    integer, intent(out) :: out
35    !ERROR: Invalid specification expression: reference to INTENT(OUT) dummy argument 'out'
36    type(t(out)) :: x4
37    integer, intent(in), optional :: optional
38    !ERROR: Invalid specification expression: reference to OPTIONAL dummy argument 'optional'
39    type(t(optional)) :: x5
40    !ERROR: Invalid specification expression: dummy procedure argument
41    type(t(hasProcArg(realfunc))) :: x6
42    !ERROR: Invalid specification expression: coindexed reference
43    type(t(coarray[1])) :: x7
44    type(t(kind(foo()))) :: x101 ! ok
45    type(t(modulefunc1(0))) :: x102 ! ok
46    type(t(modulefunc2(0))) :: x103 ! ok
47   contains
48    pure integer function internal(n)
49      integer, value :: n
50      internal = n
51    end function
52  end subroutine
53  pure integer function modulefunc2(n)
54    integer, value :: n
55    modulefunc2 = n
56  end function
57end module
58