1! RUN: %S/test_errors.sh %s %t %flang_fc1
2! REQUIRES: shell
3! Test 15.5.2.7 constraints and restrictions for POINTER dummy arguments.
4
5module m
6  real :: coarray(10)[*]
7 contains
8
9  subroutine s01(p)
10    real, pointer, contiguous, intent(in) :: p(:)
11  end subroutine
12  subroutine s02(p)
13    real, pointer :: p(:)
14  end subroutine
15  subroutine s03(p)
16    real, pointer, intent(in) :: p(:)
17  end subroutine
18
19  subroutine test
20    !ERROR: CONTIGUOUS POINTER must be an array
21    real, pointer, contiguous :: a01 ! C830
22    real, pointer :: a02(:)
23    real, target :: a03(10)
24    real :: a04(10) ! not TARGET
25    call s01(a03) ! ok
26    !ERROR: Actual argument associated with CONTIGUOUS POINTER dummy argument 'p=' must be simply contiguous
27    call s01(a02)
28    !ERROR: Actual argument associated with CONTIGUOUS POINTER dummy argument 'p=' must be simply contiguous
29    call s01(a03(::2))
30    call s02(a02) ! ok
31    call s03(a03) ! ok
32    !ERROR: Actual argument associated with POINTER dummy argument 'p=' must also be POINTER unless INTENT(IN)
33    call s02(a03)
34    !ERROR: An array section with a vector subscript may not be a pointer target
35    call s03(a03([1,2,4]))
36    !ERROR: A coindexed object may not be a pointer target
37    call s03(coarray(:)[1])
38    !ERROR: Target associated with dummy argument 'p=' must be a designator or a call to a pointer-valued function
39    call s03([1.])
40    !ERROR: In assignment to object dummy argument 'p=', the target 'a04' is not an object with POINTER or TARGET attributes
41    call s03(a04)
42  end subroutine
43end module
44