xref: /llvm-project/flang/test/Semantics/call07.f90 (revision 91917387648f5638058f7f9391f144b8858c4975)
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2! Test 15.5.2.7 constraints and restrictions for POINTER dummy arguments.
3
4module m
5  real :: coarray(10)[*]
6 contains
7
8  subroutine s01(p)
9    real, pointer, contiguous, intent(in) :: p(:)
10  end subroutine
11  subroutine s02(p)
12    real, pointer :: p(:)
13  end subroutine
14  subroutine s03(p)
15    real, pointer, intent(in) :: p(:)
16  end subroutine
17  subroutine s04(p)
18    real, pointer :: p
19  end subroutine
20
21  subroutine test
22    !PORTABILITY: CONTIGUOUS entity 'a01' should be an array pointer, assumed-shape, or assumed-rank
23    real, pointer, contiguous :: a01 ! C830
24    real, pointer :: a02(:)
25    real, target :: a03(10)
26    real :: a04(10) ! not TARGET
27    !PORTABILITY: CONTIGUOUS entity 'scalar' should be an array pointer, assumed-shape, or assumed-rank
28    real, contiguous :: scalar
29    call s01(a03) ! ok
30    !WARNING: Target of CONTIGUOUS pointer association is not known to be contiguous
31    call s01(a02)
32    !ERROR: CONTIGUOUS pointer may not be associated with a discontiguous target
33    call s01(a03(::2))
34    call s02(a02) ! ok
35    call s03(a03) ! ok
36    !ERROR: Actual argument associated with POINTER dummy argument 'p=' must also be POINTER unless INTENT(IN)
37    call s02(a03)
38    !ERROR: Actual argument associated with POINTER dummy argument 'p=' must also be POINTER unless INTENT(IN)
39    call s04(a02(1))
40    !ERROR: An array section with a vector subscript may not be a pointer target
41    call s03(a03([1,2,4]))
42    !ERROR: A coindexed object may not be a pointer target
43    call s03(coarray(:)[1])
44    !ERROR: Target associated with dummy argument 'p=' must be a designator or a call to a pointer-valued function
45    call s03([1.])
46    !ERROR: In assignment to object dummy argument 'p=', the target 'a04' is not an object with POINTER or TARGET attributes
47    call s03(a04)
48  end subroutine
49end module
50