xref: /llvm-project/flang/test/Semantics/call04.f90 (revision 2625510ef8094457413661ef0ce2651844f584d2)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Test 8.5.10 & 8.5.18 constraints on dummy argument declarations
3
4module m
5
6  type :: hasCoarray
7    real, allocatable :: a(:)[:]
8  end type
9  type, extends(hasCoarray) :: extendsHasCoarray
10  end type
11  type :: hasCoarray2
12    type(hasCoarray) :: x
13  end type
14  type, extends(hasCoarray2) :: extendsHasCoarray2
15  end type
16
17  real, allocatable :: coarray(:)[:]
18
19 contains
20
21  subroutine s01a(x)
22    real, allocatable, intent(out) :: x(:)
23  end subroutine
24  subroutine s01c(x)
25    real, intent(out) :: x(:)
26  end subroutine
27  subroutine s01b ! C846 - can only be caught at a call via explicit interface
28    !ERROR: ALLOCATABLE coarray 'coarray' may not be associated with INTENT(OUT) dummy argument 'x='
29    !ERROR: ALLOCATABLE dummy argument 'x=' has corank 0 but actual argument has corank 1
30    call s01a(coarray)
31    call s01c(coarray) ! ok, dummy is not allocatable
32  end subroutine
33
34  subroutine s02(x) ! C846
35    !ERROR: An INTENT(OUT) dummy argument may not be, or contain, an ALLOCATABLE coarray
36    type(hasCoarray), intent(out) :: x
37  end subroutine
38
39  subroutine s03(x) ! C846
40    !ERROR: An INTENT(OUT) dummy argument may not be, or contain, an ALLOCATABLE coarray
41    type(extendsHasCoarray), intent(out) :: x
42  end subroutine
43
44  subroutine s04(x) ! C846
45    !ERROR: An INTENT(OUT) dummy argument may not be, or contain, an ALLOCATABLE coarray
46    type(hasCoarray2), intent(out) :: x
47  end subroutine
48
49  subroutine s05(x) ! C846
50    !ERROR: An INTENT(OUT) dummy argument may not be, or contain, an ALLOCATABLE coarray
51    type(extendsHasCoarray2), intent(out) :: x
52  end subroutine
53
54end module
55
56subroutine s06(x) ! C847
57  use ISO_FORTRAN_ENV, only: lock_type
58  !ERROR: An INTENT(OUT) dummy argument may not be, or contain, EVENT_TYPE or LOCK_TYPE
59  type(lock_type), intent(out) :: x[*]
60end subroutine
61
62subroutine s07(x) ! C847
63  use ISO_FORTRAN_ENV, only: event_type
64  !ERROR: An INTENT(OUT) dummy argument may not be, or contain, EVENT_TYPE or LOCK_TYPE
65  type(event_type), intent(out) :: x[*]
66end subroutine
67