From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3D9833857032; Thu, 25 Feb 2021 18:40:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D9833857032 From: "kargl at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: priority cf_reconfirmed_on cc bug_status everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Feb 2021 18:40:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99256 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=20 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 =3D=3D EXPR_VARIABLE && e->symtree->n.sym->attr.intent =3D=3D INTENT_IN && (gfc_current_intrinsic_arg[n]->intent =3D=3D INTENT_OUT=