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/99256] ICE in variable_check, at fortran/check.c:1012
Date: Thu, 25 Feb 2021 18:40:13 +0000	[thread overview]
Message-ID: <bug-99256-4-xPRdcPTgjt@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99256-4@http.gcc.gnu.org/bugzilla/>

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
   Last reconfirmed|                            |2021-02-25
                 CC|                            |kargl at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from kargl at gcc dot gnu.org ---
An interesting bug.  This catches the invalid alternate return, but
there is no locus available to actually point at the offending line
of code.

e is null, so e->where does not work.

gfc_current_locus seems to point at the line 'program p'.

In check_variable(), looking at gfc_current_intrinsic_arg[n]->actual,
there is locus information.

However, there is gfc_current_intrinsic_arg[n]->actual->label->where but
this points to the line '1 stop'.  IOW, it points to where the labeled 
statement is not the where the alternate return is used.  So, the offending
line of code isn't printed.

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 82db8e4e1b2..63138cfa9bc 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -1009,6 +1009,14 @@ kind_value_check (gfc_expr *e, int n, int k)
 static bool
 variable_check (gfc_expr *e, int n, bool allow_proc)
 {
+  /* Expecting a variable, not an alternate return.  */
+  if (!e)
+    {
+      gfc_error ("%qs argument of %qs intrinsic must be a variable",
+                gfc_current_intrinsic_arg[n]->name, gfc_current_intrinsic);
+      return false;
+    }
+
   if (e->expr_type == EXPR_VARIABLE
       && e->symtree->n.sym->attr.intent == INTENT_IN
       && (gfc_current_intrinsic_arg[n]->intent == INTENT_OUT

  reply	other threads:[~2021-02-25 18:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24 17:31 [Bug fortran/99256] New: " gscfq@t-online.de
2021-02-25 18:40 ` kargl at gcc dot gnu.org [this message]
2021-02-25 18:49 ` [Bug fortran/99256] " sgk at troutmask dot apl.washington.edu
2021-12-12 21:47 ` anlauf at gcc dot gnu.org
2022-01-13 22:39 ` anlauf at gcc dot gnu.org
2022-01-13 23:08 ` kargl at gcc dot gnu.org
2022-01-14 20:48 ` cvs-commit at gcc dot gnu.org
2022-01-14 20:57 ` anlauf 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-99256-4-xPRdcPTgjt@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).