PR fortran/101565 - ICE in gfc_simplify_image_index, at fortran/simplify.c:8234

Message ID trinity-52c2addb-d7e7-4d79-8ac0-ed2b268b6947-1638221463295@3c-app-gmx-bs36
State New
Headers
Series PR fortran/101565 - ICE in gfc_simplify_image_index, at fortran/simplify.c:8234 |

Commit Message

Harald Anlauf Nov. 29, 2021, 9:31 p.m. UTC
  Dear all,

a trivial one: we need to check the type of the SUB argument
to the coarray IMAGE_INDEX intrinsic.  It has to be an array
of type integer.

Patch by Steve Kargl.

Regtested on x86_64-pc-linux-gnu.  OK for mainline?

Thanks,
Harald
  

Comments

Mikael Morin Nov. 30, 2021, 11:25 a.m. UTC | #1
Hello,

Le 29/11/2021 à 22:31, Harald Anlauf via Fortran a écrit :
> Dear all,
> 
> a trivial one: we need to check the type of the SUB argument
> to the coarray IMAGE_INDEX intrinsic.  It has to be an array
> of type integer.
> 
> Patch by Steve Kargl.
> 
I hope at some point he’ll finally come to a working git workflow.

> Regtested on x86_64-pc-linux-gnu.  OK for mainline?
> 
Sure.
  
Harald Anlauf Nov. 30, 2021, 7:47 p.m. UTC | #2
Hi Mikael,

Am 30.11.21 um 12:25 schrieb Mikael Morin:
> Hello,
>
> Le 29/11/2021 à 22:31, Harald Anlauf via Fortran a écrit :
>> Dear all,
>>
>> a trivial one: we need to check the type of the SUB argument
>> to the coarray IMAGE_INDEX intrinsic.  It has to be an array
>> of type integer.
>>
>> Patch by Steve Kargl.
>>
> I hope at some point he’ll finally come to a working git workflow.

Initially I had to rethink my workflow habits when switching from
svn to git.  But after a steep learning curve I wouldn't want to
go back.  One day Steve might see it same way.

>> Regtested on x86_64-pc-linux-gnu.  OK for mainline?
>>
> Sure.
>

Thanks,
Harald
  

Patch

From 58140e3cf97aedc5c9f3b3e6519027334cdc3213 Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
Date: Mon, 29 Nov 2021 22:23:02 +0100
Subject: [PATCH] Fortran: check type of SUB argument to IMAGE_INDEX

gcc/fortran/ChangeLog:

	PR fortran/101565
	* check.c (gfc_check_image_index): Verify that SUB argument to
	IMAGE_INDEX is of type integer.

gcc/testsuite/ChangeLog:

	PR fortran/101565
	* gfortran.dg/coarray_49.f90: New test.
---
 gcc/fortran/check.c                      | 7 +++++++
 gcc/testsuite/gfortran.dg/coarray_49.f90 | 9 +++++++++
 2 files changed, 16 insertions(+)
 create mode 100644 gcc/testsuite/gfortran.dg/coarray_49.f90

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 3e65f3d8b1f..ee3a51ee253 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -5955,6 +5955,13 @@  gfc_check_image_index (gfc_expr *coarray, gfc_expr *sub)
       return false;
     }

+  if (sub->ts.type != BT_INTEGER)
+    {
+      gfc_error ("Type of %s argument of IMAGE_INDEX at %L shall be INTEGER",
+		 gfc_current_intrinsic_arg[1]->name, &sub->where);
+      return false;
+    }
+
   if (gfc_array_size (sub, &nelems))
     {
       int corank = gfc_get_corank (coarray);
diff --git a/gcc/testsuite/gfortran.dg/coarray_49.f90 b/gcc/testsuite/gfortran.dg/coarray_49.f90
new file mode 100644
index 00000000000..370e3fd5847
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_49.f90
@@ -0,0 +1,9 @@ 
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+! PR fortran/101565 - ICE in gfc_simplify_image_index
+! Contributed by G. Steinmetz
+
+program p
+  integer :: x[*]
+  print *, image_index (x, [1.0]) ! { dg-error "shall be INTEGER" }
+end
--
2.26.2