From: Tim Keith Date: Sun, 26 Jan 2020 18:42:34 +0000 (-0800) Subject: [flang] Fix bug detecting simply contiguous component X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=56634417e7b2897f581bf30bcd30755683cc9e82;p=platform%2Fupstream%2Fllvm.git [flang] Fix bug detecting simply contiguous component We were always return false when testing a component for simple contiguity. Change to check that the component is an array that is simply continguous. Also treat a scalar component of scalar as simply contiguous. A pointer with bounds remapping to a complex part is a similar case so add a test for that too. Original-commit: flang-compiler/f18@27d76da2a44614b2c4cf4d576410372cabf66577 Reviewed-on: https://github.com/flang-compiler/f18/pull/952 --- diff --git a/flang/lib/evaluate/check-expression.cc b/flang/lib/evaluate/check-expression.cc index d9b81bd..92dbb76 100644 --- a/flang/lib/evaluate/check-expression.cc +++ b/flang/lib/evaluate/check-expression.cc @@ -283,7 +283,9 @@ public: Result operator()(const CoarrayRef &x) const { return CheckSubscripts(x.subscript()); } - Result operator()(const Component &) const { return false; } + Result operator()(const Component &x) const { + return x.base().Rank() == 0 && (*this)(x.GetLastSymbol()); + } Result operator()(const ComplexPart &) const { return false; } Result operator()(const Substring &) const { return false; } diff --git a/flang/test/semantics/assign03.f90 b/flang/test/semantics/assign03.f90 index 54112f4..08070fd 100644 --- a/flang/test/semantics/assign03.f90 +++ b/flang/test/semantics/assign03.f90 @@ -134,4 +134,29 @@ contains p(1:5,1:5) => y(1:100:2) end + subroutine s10 + integer, pointer :: p(:) + type :: t + integer :: a(4, 4) + integer :: b + end type + type(t), target :: x + type(t), target :: y(10,10) + p(1:16) => x%a + p(1:1) => x%b ! We treat scalars as simply contiguous + !ERROR: Pointer bounds remapping target must have rank 1 or be simply contiguous + p(1:4) => x%a(::2,::2) + !ERROR: Pointer bounds remapping target must have rank 1 or be simply contiguous + p(1:100) => y(:,:)%b + end + + subroutine s11 + complex, target :: x(10,10) + complex, pointer :: p(:) + real, pointer :: q(:) + p(1:100) => x(:,:) + !ERROR: Pointer bounds remapping target must have rank 1 or be simply contiguous + q(1:100) => x(:,:)%re + end + end