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