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