public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-4964] Fortran: a symbol in a COMMON cannot be a coarray
Date: Fri,  5 Nov 2021 22:15:37 +0000 (GMT)	[thread overview]
Message-ID: <20211105221537.646663858421@sourceware.org> (raw)

https://gcc.gnu.org/g:432ed97b992ccfe93616d5af1fa5c1a7d7aff9ff

commit r12-4964-g432ed97b992ccfe93616d5af1fa5c1a7d7aff9ff
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Fri Nov 5 23:13:57 2021 +0100

    Fortran: a symbol in a COMMON cannot be a coarray
    
    gcc/fortran/ChangeLog:
    
            PR fortran/69419
            * match.c (gfc_match_common): Check array spec of a symbol in a
            COMMON object list and reject it if it is a coarray.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/69419
            * gfortran.dg/pr69419.f90: New test.

Diff:
---
 gcc/fortran/match.c                   | 7 +++++++
 gcc/testsuite/gfortran.dg/pr69419.f90 | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 5d07f897e45..2bf21434a42 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -5288,6 +5288,13 @@ gfc_match_common (void)
 		  goto cleanup;
 		}
 
+	      if (as->corank)
+		{
+		  gfc_error ("Symbol %qs in COMMON at %C cannot be a "
+			     "coarray", sym->name);
+		  goto cleanup;
+		}
+
 	      if (!gfc_add_dimension (&sym->attr, sym->name, NULL))
 		goto cleanup;
 
diff --git a/gcc/testsuite/gfortran.dg/pr69419.f90 b/gcc/testsuite/gfortran.dg/pr69419.f90
new file mode 100644
index 00000000000..7329808611c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr69419.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+! PR fortran/69419 - ICE on invalid coarray in common
+
+blockdata b
+   real x           ! { dg-error "must be in COMMON" }
+   common /c/ x[*]  ! { dg-error "cannot be a coarray" }
+   data x /1.0/
+end


                 reply	other threads:[~2021-11-05 22:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211105221537.646663858421@sourceware.org \
    --to=anlauf@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).