xref: /llvm-project/flang/test/Semantics/contiguous01.f90 (revision 33c27f28d1cd05fd0a739498105927c1fba04666)
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2module m0
3  real, pointer, contiguous :: p1(:) ! ok
4  real, pointer :: p2(:)
5end
6module m
7  use m0
8  !WARNING: Use-associated 'p1' already has 'CONTIGUOUS' attribute
9  contiguous p1
10  !ERROR: Cannot change CONTIGUOUS attribute on use-associated 'p2'
11  contiguous p2
12  !PORTABILITY: CONTIGUOUS entity 'x' should be an array pointer, assumed-shape, or assumed-rank
13  real, contiguous :: x
14  !PORTABILITY: CONTIGUOUS entity 'scalar' should be an array pointer, assumed-shape, or assumed-rank
15  real, contiguous, pointer :: scalar
16  !PORTABILITY: CONTIGUOUS entity 'allocatable' should be an array pointer, assumed-shape, or assumed-rank
17  real, contiguous, allocatable :: allocatable
18 contains
19  !PORTABILITY: CONTIGUOUS entity 'func' should be an array pointer, assumed-shape, or assumed-rank
20  function func(ashape,arank) result(r)
21    real, contiguous :: ashape(:) ! ok
22    real, contiguous :: arank(..) ! ok
23    !PORTABILITY: CONTIGUOUS entity 'r' should be an array pointer, assumed-shape, or assumed-rank
24    real :: r(10)
25    !PORTABILITY: CONTIGUOUS entity 'r2' should be an array pointer, assumed-shape, or assumed-rank
26    real :: r2(10)
27    contiguous func
28    contiguous r
29    contiguous e
30    contiguous r2
31    !PORTABILITY: CONTIGUOUS entity 'e' should be an array pointer, assumed-shape, or assumed-rank
32    entry e() result(r2)
33    r2 = 0
34  end
35  function fp()
36    real, pointer, contiguous :: fp(:) ! ok
37    nullify(fp)
38  end
39end
40