public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5634] Fortran: check type of SUB argument to IMAGE_INDEX
@ 2021-11-30 19:39 Harald Anlauf
0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2021-11-30 19:39 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:814f52a8bfc66aff8c453b040f0e730b034b7f52
commit r12-5634-g814f52a8bfc66aff8c453b040f0e730b034b7f52
Author: Harald Anlauf <anlauf@gmx.de>
Date: Mon Nov 29 22:23:02 2021 +0100
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.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
Diff:
---
gcc/fortran/check.c | 7 +++++++
gcc/testsuite/gfortran.dg/coarray_49.f90 | 9 +++++++++
2 files changed, 16 insertions(+)
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-11-30 19:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 19:39 [gcc r12-5634] Fortran: check type of SUB argument to IMAGE_INDEX Harald Anlauf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).