public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/102331] ICE in attr_decl1, at fortran/decl.c:8691
Date: Wed, 15 Sep 2021 17:20:44 +0000	[thread overview]
Message-ID: <bug-102331-4-4s0hidLJ8q@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102331-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102331

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #2 from kargl at gcc dot gnu.org ---
The following patch fixes the problem.  It has not been regression tested.

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 05081c40f1e..85c95cea17f 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -8695,7 +8695,9 @@ attr_decl1 (void)
   /* Update symbol table.  DIMENSION attribute is set in
      gfc_set_array_spec().  For CLASS variables, this must be applied
      to the first component, or '_data' field.  */
-  if (sym->ts.type == BT_CLASS && sym->ts.u.derived->attr.is_class)
+  if (sym->ts.type == BT_CLASS
+      && sym->ts.u.derived
+      && sym->ts.u.derived->attr.is_class)
     {
       /* gfc_set_array_spec sets sym->attr not CLASS_DATA(sym)->attr.  Check
         for duplicate attribute here.  */
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 6d7845e8517..8d6d4f4e98f 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -3813,7 +3813,7 @@ match_deferred_characteristics (gfc_typespec * ts)
   m = gfc_match_prefix (ts);
   gfc_buffer_error (false);

-  if (ts->type == BT_DERIVED)
+  if (ts->type == BT_DERIVED || ts->type == BT_CLASS)
     {
       ts->kind = 0;

@@ -4094,7 +4094,7 @@ declSt:
   if (bad_characteristic)
     {
       ts = &gfc_current_block ()->result->ts;
-      if (ts->type != BT_DERIVED)
+      if (ts->type != BT_DERIVED && ts->type != BT_CLASS)
        gfc_error ("Bad kind expression for function %qs at %L",
                   gfc_current_block ()->name,
                   &gfc_current_block ()->declared_at);

  parent reply	other threads:[~2021-09-15 17:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14 17:29 [Bug fortran/102331] New: " gscfq@t-online.de
2021-09-14 17:29 ` [Bug fortran/102331] " gscfq@t-online.de
2021-09-15  8:51 ` marxin at gcc dot gnu.org
2021-09-15 17:20 ` kargl at gcc dot gnu.org [this message]
2021-09-15 20:57 ` anlauf at gcc dot gnu.org
2021-09-15 21:59 ` sgk at troutmask dot apl.washington.edu
2022-12-26 19:55 ` jvdelisle at gcc dot gnu.org
2022-12-26 20:14 ` jvdelisle at gcc dot gnu.org
2023-01-14  3:29 ` jvdelisle at gcc dot gnu.org
2023-01-18  1:37 ` jvdelisle at gcc dot gnu.org
2023-03-27  2:00 ` cvs-commit at gcc dot gnu.org
2023-05-29 22:06 ` kargl at gcc dot gnu.org

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=bug-102331-4-4s0hidLJ8q@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).