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/99139] ICE: gfc_get_default_type(): Bad symbol '__tmp_UNKNOWN_0_rank_1'
Date: Sun, 28 May 2023 15:29:30 +0000	[thread overview]
Message-ID: <bug-99139-4-yvO24gL88l@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99139-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from kargl at gcc dot gnu.org ---
(In reply to sandra from comment #4)
> The problem noted in comment 1 looks related to PR 102641 --
> automatically-inserted implicit initialization code can't cope with
> assumed-rank arrays.

I don't think it is related.  PR102601 involves default initialization
and/or deallocation of an actual argument associated with an intent(out)
assumed-rank dummy argument.

> I tested the patch in comment 2 and saw a whole lot of regressions (ICEs). 
> :-(

The patch in comment #2 needed to be moved down into the 'if (m == MATCH_YES)'
block where 'expr2 != NULL'.  The following has been regtested with no new
regressions.

diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index 5eb6d0e1c1d..0a030ae01df 100644
--- a/gcc/fortran/match.cc
+++ b/gcc/fortran/match.cc
@@ -6770,8 +6770,20 @@ gfc_match_select_rank (void)

   gfc_current_ns = gfc_build_block_ns (ns);
   m = gfc_match (" %n => %e", name, &expr2);
+
   if (m == MATCH_YES)
     {
+      /* If expr2 corresponds to an implicitly typed variable, then the
+        actual type of the variable may not have been set.  Set it here.  */
+      if (!gfc_current_ns->seen_implicit_none 
+         && expr2->expr_type == EXPR_VARIABLE
+         && expr2->ts.type == BT_UNKNOWN
+         && expr2->symtree && expr2->symtree->n.sym)
+       {
+         gfc_set_default_type (expr2->symtree->n.sym, 0, gfc_current_ns);
+         expr2->ts.type = expr2->symtree->n.sym->ts.type;
+       }    
+
       expr1 = gfc_get_expr ();
       expr1->expr_type = EXPR_VARIABLE;
       expr1->where = expr2->where;

  parent reply	other threads:[~2023-05-28 15:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17 18:12 [Bug fortran/99139] New: " gscfq@t-online.de
2021-02-17 18:13 ` [Bug fortran/99139] " gscfq@t-online.de
2021-02-17 19:49 ` kargl at gcc dot gnu.org
2021-02-18  8:42 ` marxin at gcc dot gnu.org
2021-10-24  5:51 ` sandra at gcc dot gnu.org
2023-05-28 15:29 ` kargl at gcc dot gnu.org [this message]
2023-07-08 17:13 ` cvs-commit at gcc dot gnu.org
2023-07-14 18:54 ` anlauf at gcc dot gnu.org
2023-07-15  6:15 ` pault at gcc dot gnu.org
2023-07-15  7:50 ` sgk at troutmask dot apl.washington.edu

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-99139-4-yvO24gL88l@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).