Skip to content

Commit 51a2ac6

Browse files
authored
[flang] Fold IS_CONTIGUOUS of component refs with non-contiguous base (#69327)
1 parent 112e49b commit 51a2ac6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

flang/lib/Evaluate/check-expression.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,13 @@ class IsContiguousHelper
821821
if (x.base().Rank() == 0) {
822822
return (*this)(x.GetLastSymbol());
823823
} else {
824-
// TODO could be true if base contiguous and this is only component, or
825-
// if base has only one element?
824+
if (Result baseIsContiguous{(*this)(x.base())}) {
825+
if (!*baseIsContiguous) {
826+
return false;
827+
}
828+
// TODO could be true if base contiguous and this is only component, or
829+
// if base has only one element?
830+
}
826831
return std::nullopt;
827832
}
828833
}

flang/test/Evaluate/folding09.f90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,13 @@ subroutine test(arr1, arr2, arr3, mat, alloc)
5656
end block
5757
end associate
5858
end subroutine
59+
subroutine test2(x, vec)
60+
type t
61+
integer :: i
62+
end type
63+
type(t) :: x(100)
64+
integer(8) :: vec(10)
65+
integer(kind=merge(1,-1, .not. is_contiguous(x(1:50:2)%i))) t01
66+
integer(kind=merge(1,-1, .not. is_contiguous(x(vec)%i))) t02
67+
end subroutine
5968
end module

0 commit comments

Comments
 (0)