From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 50E38386EC57; Mon, 31 Aug 2020 19:49:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50E38386EC57 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598903384; bh=0X4pjBJ8WQ64F2o7AeOVavMpVexEZ71iq1U2kd9ROf8=; h=From:To:Subject:Date:From; b=Qfa/75HEaHeyCkyOxmqTefoZ8ZRBlUdDPEGjrfVYKSdryqzTxcDjsNGWMQwUkYzFw gXhRQ4bV4CEI4oO3IbgCu6A4szwR7qH4kxVndAV4P2CaEdaeTk4avQsUrHSU4f5LlK 3ZNMvwxvo/qgCbxzk2wg7ncI12/6NAZgLOkqaxOc= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: =?utf-8?q?=5Bgcc/devel/c++-coroutines=5D_=092020-8-20__Jos=C3=A9_Rui_Faus?= =?utf-8?q?tino_de_Sousa__=3Cjrfsousa=40gmail=2Ecom=3E?= X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Jos=C3=A9_Rui_Faustino_de_Sousa?= X-Git-Refname: refs/heads/devel/c++-coroutines X-Git-Oldrev: cd49b7067893b548a10c99ea0cb6aba2977eef2e X-Git-Newrev: 8f7d99acf6d94eed6a7f9b9f76bd4c2243c660b2 Message-Id: <20200831194944.50E38386EC57@sourceware.org> Date: Mon, 31 Aug 2020 19:49:44 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Aug 2020 19:49:44 -0000 https://gcc.gnu.org/g:8f7d99acf6d94eed6a7f9b9f76bd4c2243c660b2 commit 8f7d99acf6d94eed6a7f9b9f76bd4c2243c660b2 Author: José Rui Faustino de Sousa Date: Sun Aug 30 17:58:13 2020 +0000 2020-8-20 José Rui Faustino de Sousa gcc/fortran/ChangeLog: PR fortran/96726 * expr.c (check_references): Change different relational operator to less-than operator to avoid infinite loop. gcc/testsuite/ChangeLog: PR fortran/96726 * gfortran.dg/PR96726.f90: New test. Diff: --- gcc/fortran/expr.c | 2 +- gcc/testsuite/gfortran.dg/PR96726.f90 | 72 +++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 6707ca550a0..2ef01f0f14f 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3273,7 +3273,7 @@ check_references (gfc_ref* ref, bool (*checker) (gfc_expr*)) switch (ref->type) { case REF_ARRAY: - for (dim = 0; dim != ref->u.ar.dimen; ++dim) + for (dim = 0; dim < ref->u.ar.dimen; ++dim) { if (!checker (ref->u.ar.start[dim])) return false; diff --git a/gcc/testsuite/gfortran.dg/PR96726.f90 b/gcc/testsuite/gfortran.dg/PR96726.f90 new file mode 100644 index 00000000000..b0b26b90669 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR96726.f90 @@ -0,0 +1,72 @@ +! { dg-do run } +! +! Test the fix for PR96726 +! + +module cref_m + + implicit none + + private + + public :: & + sizeish + +contains + + pure function sizeish(a) result(s) + integer, intent(in) :: a(..) + + integer :: s + + s = size(a) + return + end function sizeish + +end module cref_m + +program cref_p + + use cref_m, only: & + sizeish + + implicit none + + integer :: i + + integer, parameter :: n = 3 + integer, parameter :: p(*) = [(i, i=1,n*n)] + + integer :: a(n,n) + integer :: b(n*n) + + a = reshape(p, shape=[n,n]) + call isub_a(a, b) + if (any(b/=p)) stop 1 + call isub_b(a, b) + if (any(b/=p)) stop 2 + stop + +contains + + subroutine isub_a(a, b) + integer, intent(in) :: a(..) + integer, intent(out) :: b(size(a)) + + integer :: i + + b = [(i, i=1,size(b))] + return + end subroutine isub_a + + subroutine isub_b(a, b) + integer, intent(in) :: a(..) + integer, intent(out) :: b(sizeish(a)) + + integer :: i + + b = [(i, i=1,sizeish(b))] + return + end subroutine isub_b + +end program cref_p