1! RUN: %S/test_errors.sh %s %t %flang_fc1
2! REQUIRES: shell
3! Test 15.5.2.6 constraints and restrictions for ALLOCATABLE
4! dummy arguments.
5
6module m
7
8  real, allocatable :: cov[:], com[:,:]
9
10 contains
11
12  subroutine s01(x)
13    real, allocatable :: x
14  end subroutine
15  subroutine s02(x)
16    real, allocatable :: x[:]
17  end subroutine
18  subroutine s03(x)
19    real, allocatable :: x[:,:]
20  end subroutine
21  subroutine s04(x)
22    real, allocatable, intent(in) :: x
23  end subroutine
24  subroutine s05(x)
25    real, allocatable, intent(out) :: x
26  end subroutine
27  subroutine s06(x)
28    real, allocatable, intent(in out) :: x
29  end subroutine
30  function allofunc()
31    real, allocatable :: allofunc
32  end function
33
34  subroutine test(x)
35    real :: scalar
36    real, allocatable, intent(in) :: x
37    !ERROR: ALLOCATABLE dummy argument 'x=' must be associated with an ALLOCATABLE actual argument
38    call s01(scalar)
39    !ERROR: ALLOCATABLE dummy argument 'x=' must be associated with an ALLOCATABLE actual argument
40    call s01(1.)
41    !ERROR: ALLOCATABLE dummy argument 'x=' must be associated with an ALLOCATABLE actual argument
42    call s01(allofunc()) ! subtle: ALLOCATABLE function result isn't
43    call s02(cov) ! ok
44    call s03(com) ! ok
45    !ERROR: ALLOCATABLE dummy argument 'x=' has corank 1 but actual argument has corank 2
46    call s02(com)
47    !ERROR: ALLOCATABLE dummy argument 'x=' has corank 2 but actual argument has corank 1
48    call s03(cov)
49    call s04(cov[1]) ! ok
50    !ERROR: ALLOCATABLE dummy argument 'x=' must have INTENT(IN) to be associated with a coindexed actual argument
51    call s01(cov[1])
52    !ERROR: Actual argument associated with INTENT(OUT) dummy argument 'x=' must be definable
53    call s05(x)
54    !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'x=' must be definable
55    call s06(x)
56  end subroutine
57end module
58