1! RUN: %S/test_errors.sh %s %t %f18
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 s01b ! C846 - can only be caught at a call via explicit interface
25    !ERROR: ALLOCATABLE coarray 'coarray' may not be associated with INTENT(OUT) dummy argument 'x='
26    !ERROR: ALLOCATABLE dummy argument 'x=' has corank 0 but actual argument has corank 1
27    call s01a(coarray)
28  end subroutine
29
30  subroutine s02(x) ! C846
31    !ERROR: An INTENT(OUT) dummy argument may not be, or contain, an ALLOCATABLE coarray
32    type(hasCoarray), intent(out) :: x
33  end subroutine
34
35  subroutine s03(x) ! C846
36    !ERROR: An INTENT(OUT) dummy argument may not be, or contain, an ALLOCATABLE coarray
37    type(extendsHasCoarray), intent(out) :: x
38  end subroutine
39
40  subroutine s04(x) ! C846
41    !ERROR: An INTENT(OUT) dummy argument may not be, or contain, an ALLOCATABLE coarray
42    type(hasCoarray2), intent(out) :: x
43  end subroutine
44
45  subroutine s05(x) ! C846
46    !ERROR: An INTENT(OUT) dummy argument may not be, or contain, an ALLOCATABLE coarray
47    type(extendsHasCoarray2), intent(out) :: x
48  end subroutine
49
50end module
51
52subroutine s06(x) ! C847
53  use ISO_FORTRAN_ENV, only: lock_type
54  !ERROR: An INTENT(OUT) dummy argument may not be, or contain, EVENT_TYPE or LOCK_TYPE
55  type(lock_type), intent(out) :: x
56end subroutine
57
58subroutine s07(x) ! C847
59  use ISO_FORTRAN_ENV, only: event_type
60  !ERROR: An INTENT(OUT) dummy argument may not be, or contain, EVENT_TYPE or LOCK_TYPE
61  type(event_type), intent(out) :: x
62end subroutine
63