Fortran : ICE in gfc_find_array_ref(): No ref found PR95981

Message ID c9c0fe7c-dcc1-a7c7-2d8b-e010387aa98c@codethink.co.uk
State New
Headers show
Series
  • Fortran : ICE in gfc_find_array_ref(): No ref found PR95981
Related show

Commit Message

Mark Eggleston July 1, 2020, 6:56 a.m.
Please find attached a patch to fix PR95981.  Original patch by Steve Kargl.

OK to commit and backport?

Commit message:

Fortran  :  ICE in gfc_find_array_ref(): No ref found PR95981

When looking for an array reference allow NULL references.  If
no array reference is found dim_rank_check should return false.

2020-07-01  Steven G. Kargl  <kargl@gcc.gnu.org>

gcc/fortran/

     PR fortran/95981
     * check.c (dim_rank_check): Allow NULL references in call to
     gfc_find_array_ref and return false if no reference is found.

2020-07-01  Mark Eggleston <markeggleston@gcc.gnu.org>

gcc/testsuite/

     PR fortran/95981
     * gfortran.dg/pr95981.f90: New test.

-- 
https://www.codethink.co.uk/privacy.html

Comments

Mark Eggleston July 10, 2020, 7:25 a.m. | #1
ping

On 01/07/2020 07:56, Mark Eggleston wrote:
> Please find attached a patch to fix PR95981.  Original patch by Steve 

> Kargl.

>

> OK to commit and backport?

>

> Commit message:

>

> Fortran  :  ICE in gfc_find_array_ref(): No ref found PR95981

>

> When looking for an array reference allow NULL references.  If

> no array reference is found dim_rank_check should return false.

>

> 2020-07-01  Steven G. Kargl  <kargl@gcc.gnu.org>

>

> gcc/fortran/

>

>     PR fortran/95981

>     * check.c (dim_rank_check): Allow NULL references in call to

>     gfc_find_array_ref and return false if no reference is found.

>

> 2020-07-01  Mark Eggleston <markeggleston@gcc.gnu.org>

>

> gcc/testsuite/

>

>     PR fortran/95981

>     * gfortran.dg/pr95981.f90: New test.

>

-- 
https://www.codethink.co.uk/privacy.html
Jakub Jelinek via Gcc-patches July 10, 2020, 5:30 p.m. | #2
Hi Mark,

> Fortran  :  ICE in gfc_find_array_ref(): No ref found PR95981


OK for master.  With regards to backporting, copy & paste my
remarks from the previous e-mails :-)

Best regards

	Thomas

Patch

From 137ae7db6e494eca7ddf4e8a526b0343683b461b Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggleston@gcc.gnu.org>
Date: Tue, 30 Jun 2020 10:15:05 +0100
Subject: [PATCH] Fortran  :  ICE in gfc_find_array_ref(): No ref found PR95981

When looking for an array reference allow NULL references.  If
no array reference is found dim_rank_check should return false.

2020-07-01  Steven G. Kargl  <kargl@gcc.gnu.org>

gcc/fortran/

	PR fortran/95981
	* check.c (dim_rank_check): Allow NULL references in call to
	gfc_find_array_ref and return false if no reference is found.

2020-07-01  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite/

	PR fortran/95981
	* gfortran.dg/pr95981.f90: New test.
---
 gcc/fortran/check.c                   | 4 +++-
 gcc/testsuite/gfortran.dg/pr95981.f90 | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gfortran.dg/pr95981.f90

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index de9a45fe4f9..9e792a847bc 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -1142,7 +1142,9 @@  dim_rank_check (gfc_expr *dim, gfc_expr *array, int allow_assumed)
 
   if (array->expr_type == EXPR_VARIABLE)
     {
-      ar = gfc_find_array_ref (array);
+      ar = gfc_find_array_ref (array, true);
+      if (!ar)
+	return false;
       if (ar->as->type == AS_ASSUMED_SIZE
 	  && !allow_assumed
 	  && ar->type != AR_ELEMENT
diff --git a/gcc/testsuite/gfortran.dg/pr95981.f90 b/gcc/testsuite/gfortran.dg/pr95981.f90
new file mode 100644
index 00000000000..7da6e9bd3dd
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95981.f90
@@ -0,0 +1,9 @@ 
+! { dg-do compile }
+
+program p
+   type t
+   end type
+   class(t) :: x(:)        ! { dg-error "must be dummy, allocatable or pointer" }
+   type(t) :: y(size(x,1)) ! { dg-error "must be constant of INTEGER type" }
+end
+
-- 
2.11.0