public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR fortran/93834 - [9/10/11/12 Regression] ICE in trans_caf_is_present, at fortran/trans-intrinsic.c:8469
@ 2021-08-24 20:36 Harald Anlauf
  2021-08-31 19:05 ` *PING* " Harald Anlauf
  2021-09-02 10:21 ` Tobias Burnus
  0 siblings, 2 replies; 10+ messages in thread
From: Harald Anlauf @ 2021-08-24 20:36 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

Dear Fortranners,

here's a pretty obvious one: we didn't properly check the arguments
for intrinsics when these had to be ALLOCATABLE and in the case that
argument was a coarray object.  Simple solution: just reuse a check
that was used for pointer etc.

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

Thanks,
Harald


Fortran - extend allocatable_check to coarrays

gcc/fortran/ChangeLog:

	PR fortran/93834
	* check.c (allocatable_check): A coindexed array element is not an
	allocatable object.

gcc/testsuite/ChangeLog:

	PR fortran/93834
	* gfortran.dg/coarray_allocated.f90: New test.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pr93834.patch --]
[-- Type: text/x-patch, Size: 1033 bytes --]

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 851af1b30dc..a293a7b9592 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -983,6 +983,14 @@ allocatable_check (gfc_expr *e, int n)
       return false;
     }

+  if (attr.codimension && gfc_is_coindexed (e))
+    {
+      gfc_error ("%qs argument of %qs intrinsic at %L shall not be "
+		 "coindexed", gfc_current_intrinsic_arg[n]->name,
+		 gfc_current_intrinsic, &e->where);
+      return false;
+    }
+
   return true;
 }

diff --git a/gcc/testsuite/gfortran.dg/coarray_allocated.f90 b/gcc/testsuite/gfortran.dg/coarray_allocated.f90
new file mode 100644
index 00000000000..70e865c94ac
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_allocated.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+! PR fortran/93834 - ICE in trans_caf_is_present
+
+program p
+  integer, allocatable :: a[:]
+  print *, allocated (a)
+  print *, allocated (a[1]) ! { dg-error "shall not be coindexed" }
+end

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-09-23 16:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 20:36 [PATCH] PR fortran/93834 - [9/10/11/12 Regression] ICE in trans_caf_is_present, at fortran/trans-intrinsic.c:8469 Harald Anlauf
2021-08-31 19:05 ` *PING* " Harald Anlauf
2021-09-02 10:21 ` Tobias Burnus
2021-09-02 18:36   ` Harald Anlauf
2021-09-07  8:02     ` Tobias Burnus
2021-09-07 14:33       ` [Patch] Fortran: Handle allocated() with coindexed scalars [PR93834] (was: [PATCH] PR fortran/93834 - [9/10/11/12 Regression] ICE in trans_caf_is_present, at fortran/trans-intrinsic.c:8469) Tobias Burnus
2021-09-07 18:15         ` Harald Anlauf
2021-09-16 12:26         ` PING – " Tobias Burnus
2021-09-22 16:55           ` PING**2 " Tobias Burnus
     [not found]         ` <sig181$fc9$1@ciao.gmane.io>
2021-09-23 16:56           ` Tobias Burnus

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).