public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, 8/9/10 Regression] fortran: ICE equivalence with an element of an array PR94030
@ 2020-03-30  7:30 Mark Eggleston
  2020-03-30  7:59 ` Tobias Burnus
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Eggleston @ 2020-03-30  7:30 UTC (permalink / raw)
  To: fortran, gcc-patches

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

Please find attached patch for PR94030.

OK to commit?

gcc/fortran/ChangeLog:

     Steven G. Kargl  <kargl@gcc.gnu.org>

     PR fortran/94030
     * resolve.c (resolve_equivalence): Correct formatting
     around the label "identical_types".  Instead of using
     gfc_resolve_array_spec use is_non_constants_shape_array
     to determine whether the array can be used in a in an
     equivalence statement.

gcc/testsuite/ChangeLog:

     Mark Eggleston  <mark.eggleston@codethink.com>
     Steven G. Kargl  <kargl@gcc.gnu.org>

     PR fortran/94030
     * gfortran.dg/pr94030_1.f90: New test.
     * gfortran.dg/pr94030_2.f90: New test.

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


[-- Attachment #2: 0001-fortran-ICE-equivalence-with-an-element-of-an-array-.patch --]
[-- Type: text/x-patch, Size: 3196 bytes --]

From 28562d99f2bc7c9418baf707c602bbf7aefbeec3 Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggleston@gcc.gnu.org>
Date: Fri, 27 Mar 2020 11:30:40 +0000
Subject: [PATCH] fortran: ICE equivalence with an element of an array PR94030

Deferred size arrays can not be used in equivalance statements.

gcc/fortran/ChangeLog:

	PR fortran/94030
	* resolve.c (resolve_equivalence): Correct formatting
	around the label "identical_types".  Instead of using
	gfc_resolve_array_spec use is_non_constants_shape_array
	to determine whether the array can be used in a in an
	equivalence statement.

gcc/testsuite/ChangeLog:

	PR fortran/94030
	* gfortran.dg/pr94030_1.f90
	* gfortran.dg/pr94030_2.f90
---
 gcc/fortran/resolve.c                   |  6 +++---
 gcc/testsuite/gfortran.dg/pr94030_1.f90 | 11 +++++++++++
 gcc/testsuite/gfortran.dg/pr94030_2.f90 | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/pr94030_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/pr94030_2.f90

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 2dcb261fc71..bfafd3de07a 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -16855,7 +16855,8 @@ resolve_equivalence (gfc_equiv *eq)
 	  && !gfc_notify_std (GFC_STD_GNU, msg, sym->name, &e->where))
 		continue;
 
-  identical_types:
+identical_types:
+
       last_ts =&sym->ts;
       last_where = &e->where;
 
@@ -16863,8 +16864,7 @@ resolve_equivalence (gfc_equiv *eq)
 	continue;
 
       /* Shall not be an automatic array.  */
-      if (e->ref->type == REF_ARRAY
-	  && !gfc_resolve_array_spec (e->ref->u.ar.as, 1))
+      if (e->ref->type == REF_ARRAY && is_non_constant_shape_array (sym))
 	{
 	  gfc_error ("Array %qs at %L with non-constant bounds cannot be "
 		     "an EQUIVALENCE object", sym->name, &e->where);
diff --git a/gcc/testsuite/gfortran.dg/pr94030_1.f90 b/gcc/testsuite/gfortran.dg/pr94030_1.f90
new file mode 100644
index 00000000000..e63d3cc8da4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr94030_1.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+!
+
+subroutine f(n)
+  integer :: n
+  integer :: arr(n)
+  integer :: i
+  equivalence (i, arr(1))
+end
+
+! { dg-error "Array 'arr' at .1. with non-constant bounds cannot be an EQUIVALENCE object" " " { target *-*-* } 8 }
diff --git a/gcc/testsuite/gfortran.dg/pr94030_2.f90 b/gcc/testsuite/gfortran.dg/pr94030_2.f90
new file mode 100644
index 00000000000..84bfdeaa819
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr94030_2.f90
@@ -0,0 +1,33 @@
+! { dg-do compile }
+!
+! Provided by Steve Kargl.
+
+subroutine foo(n,m)
+  integer, intent(in) :: n, m
+  integer a(n)
+  real b(n)
+  equivalence(a,b)
+  if (m /= 2) then
+      a = 1
+      print *, a(1)
+  else
+      b = 42.
+      print *, b(1)
+   end if
+end subroutine 
+
+subroutine bar(m)
+  integer, intent(in) :: m
+  integer x(8)
+  real y(8)
+  equivalence(x,y)
+  if (m /= 2) then
+      x = 1
+      print *, x(1)
+  else
+      y = 42.
+      print *, y(1)
+   end if
+end subroutine 
+
+! { dg-error "Array '.' at .1. with non-constant bounds cannot be an EQUIVALENCE object" " " { target *-*-* } 9 }
-- 
2.11.0


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

* Re: [PATCH, 8/9/10 Regression] fortran: ICE equivalence with an element of an array PR94030
  2020-03-30  7:30 [PATCH, 8/9/10 Regression] fortran: ICE equivalence with an element of an array PR94030 Mark Eggleston
@ 2020-03-30  7:59 ` Tobias Burnus
  0 siblings, 0 replies; 2+ messages in thread
From: Tobias Burnus @ 2020-03-30  7:59 UTC (permalink / raw)
  To: Mark Eggleston, fortran, gcc-patches

OK.

Thanks,

Tobias

On 3/30/20 9:30 AM, Mark Eggleston wrote:

> Please find attached patch for PR94030.
>
> OK to commit?
>
> gcc/fortran/ChangeLog:
>
>     Steven G. Kargl  <kargl@gcc.gnu.org>
>
>     PR fortran/94030
>     * resolve.c (resolve_equivalence): Correct formatting
>     around the label "identical_types".  Instead of using
>     gfc_resolve_array_spec use is_non_constants_shape_array
>     to determine whether the array can be used in a in an
>     equivalence statement.
>
> gcc/testsuite/ChangeLog:
>
>     Mark Eggleston  <mark.eggleston@codethink.com>
>     Steven G. Kargl  <kargl@gcc.gnu.org>
>
>     PR fortran/94030
>     * gfortran.dg/pr94030_1.f90: New test.
>     * gfortran.dg/pr94030_2.f90: New test.
>
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

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

end of thread, other threads:[~2020-03-30  7:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30  7:30 [PATCH, 8/9/10 Regression] fortran: ICE equivalence with an element of an array PR94030 Mark Eggleston
2020-03-30  7:59 ` 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).