1 ! RUN: %python %S/test_folding.py %s %flang_fc1
2 ! Test folding of IS_CONTIGUOUS
5 real, target
:: hosted(2)
6 integer, parameter :: cst(2,2) = reshape([1, 2, 3, 4], shape(cst
))
7 integer, parameter :: empty_cst(2,0) = reshape([1], shape(empty_cst
))
9 logical, parameter :: test_param1
= is_contiguous(cst(:,1))
10 logical, parameter :: test_param2
= is_contiguous(cst(1,:))
11 logical, parameter :: test_param3
= is_contiguous(cst(:,n
))
12 logical, parameter :: test_param4
= .not
. is_contiguous(cst(n
,:))
13 logical, parameter :: test_param5
= is_contiguous(empty_cst(n
,-1:n
:2))
16 real, pointer, contiguous
:: f(:)
19 subroutine test(arr1
, arr2
, arr3
, mat
, alloc
)
20 real, intent(in
) :: arr1(:), arr2(10), mat(10, 10)
21 real, intent(in
), contiguous
:: arr3(:)
22 real, allocatable
:: alloc(:)
24 integer(kind
=merge(1,-1, is_contiguous(0))) t01
25 integer(kind
=merge(1,-1, is_contiguous(scalar
))) t02
26 integer(kind
=merge(1,-1, is_contiguous(scalar
+ scalar
))) t03
27 integer(kind
=merge(1,-1, is_contiguous([0, 1, 2]))) t04
28 integer(kind
=merge(1,-1, is_contiguous(arr1
+ 1.0))) t05
29 integer(kind
=merge(1,-1, is_contiguous(arr2
))) t06
30 integer(kind
=merge(1,-1, is_contiguous(mat
))) t07
31 integer(kind
=merge(1,-1, is_contiguous(mat(1:10,1)))) t08
32 integer(kind
=merge(1,-1, is_contiguous(arr2(1:10:1)))) t09
33 integer(kind
=merge(1,-1, .not
. is_contiguous(arr2(1:10:2)))) t10
34 integer(kind
=merge(1,-1, is_contiguous(arr3
))) t11
35 integer(kind
=merge(1,-1, .not
. is_contiguous(arr3(1:10:2)))) t12
36 integer(kind
=merge(1,-1, is_contiguous(f()))) t13
37 integer(kind
=merge(1,-1, is_contiguous(alloc
))) t14
40 integer(kind
=merge(1,-1,is_contiguous(x
))) n
43 associate (x
=> arr2(1:10:2))
45 integer(kind
=merge(1,-1,.not
. is_contiguous(x
))) n
50 integer(kind
=merge(1,-1,is_contiguous(x
))) n
53 associate (x
=> arr3(1:10:2))
55 integer(kind
=merge(1,-1,.not
. is_contiguous(x
))) n