public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: fortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] PR fortran/98284 - ICE in get_array_index
Date: Tue, 15 Dec 2020 21:58:41 +0100	[thread overview]
Message-ID: <trinity-bac7d7a0-1bfc-4daa-b2ba-fd1535232bc5-1608065921455@3c-app-gmx-bap04> (raw)

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

Dear all,

ICE-on-invalid: testcase by Arseny, draft patch by Steve,
slightly polished and regtested by me on x86_64-pc-linux-gnu.

OK for master?

Thanks,
Harald


PR fortran/98284 - ICE in get_array_index

Reject DATA elements with the ALLOCATABLE attribute also when they are
components of a derived type.

gcc/fortran/ChangeLog:

	PR fortran/98284
	* resolve.c (check_data_variable): Reject DATA elements with the
	ALLOCATABLE attribute.

gcc/testsuite/ChangeLog:

	PR fortran/98284
	* gfortran.dg/pr98284.f90: New test.


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

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 327dffbebf2..05a5e43c90b 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -16169,6 +16169,13 @@ check_data_variable (gfc_data_variable *var, locus *where)
 	      return false;
 	    }
 	}
+
+      if (ref->type == REF_COMPONENT && ref->u.c.component->attr.allocatable)
+	{
+	  gfc_error ("DATA element %qs at %L cannot have the ALLOCATABLE "
+		     "attribute", ref->u.c.component->name, &e->where);
+	  return false;
+	}
     }

   if (e->rank == 0 || has_pointer)
diff --git a/gcc/testsuite/gfortran.dg/pr98284.f90 b/gcc/testsuite/gfortran.dg/pr98284.f90
new file mode 100644
index 00000000000..aa4b95c667c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr98284.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR fortran/98284 - ICE in get_array_index
+
+program p
+  implicit none
+  type t
+     integer, allocatable :: h(:)
+  end type t
+  type(t) :: u
+  integer :: i
+  data (u% h(i),i=1,8) /8*1/ ! { dg-error "cannot have the ALLOCATABLE attribute" }
+end

             reply	other threads:[~2020-12-15 20:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-15 20:58 Harald Anlauf [this message]
2020-12-16 12:22 ` Thomas Koenig

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=trinity-bac7d7a0-1bfc-4daa-b2ba-fd1535232bc5-1608065921455@3c-app-gmx-bap04 \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@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).