From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2BC76383F845; Tue, 12 May 2020 20:21:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BC76383F845 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589314910; bh=aCxxAkCsDojdLTS/CBVO4QLib0VGdanWIqAPChFUZig=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nI/ZseU7hQ04Jy2M4uJAAbsLKuFMlW9iJ316OC+A8RX8hVWEJXw5sTu1HFcUZa6nr VWmbYVmjFrZO72SKFqZbik+VjiT/soXvMvfXHlKxpRu9KOYa9/xlf/Hxw7+Tfi6gk+ JzFS/089PCKXFAUjTI7GI1vytEtPpnJLaNTG+8bs= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/95053] [11 regression] ICE in f951: gfc_divide() Date: Tue, 12 May 2020 20:21:49 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: anlauf at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status resolution 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: Tue, 12 May 2020 20:21:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95053 anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED |--- --- Comment #15 from anlauf at gcc dot gnu.org --- A possible workaround is to partly revert the offending commit and handle problematic cases individually. The original commit intended to handle two different ICEs with a common invalid code. Bill, can you try the following patch? (Note that this needs two adjustmen= ts in the testsuite, but otherwise regtests for me. I'm not 100%sure if the PDT part is correct.) diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c index dd72f44d377..dd7f5f43930 100644 --- a/gcc/fortran/arith.c +++ b/gcc/fortran/arith.c @@ -1806,7 +1806,7 @@ gfc_multiply (gfc_expr *op1, gfc_expr *op2) gfc_expr * gfc_divide (gfc_expr *op1, gfc_expr *op2) { - if (op2 && op2->expr_type =3D=3D EXPR_CONSTANT) + if (0 && op2 && op2->expr_type =3D=3D EXPR_CONSTANT) { arith rc =3D ARITH_OK; switch (op2->ts.type) diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index d650407da41..6866f460224 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -2602,6 +2602,14 @@ variable_decl (int elem) gfc_free_expr (e); } + if (not_constant && e->ts.type !=3D BT_INTEGER) + { + gfc_error ("Explicit array shape at %C must be constant of " + "INTEGER type and not %s type", + gfc_basic_typename (e->ts.type)); + m =3D MATCH_ERROR; + goto cleanup; + } if (not_constant) { gfc_error ("Explicit shaped array with nonconstant bounds at %C"); @@ -3736,8 +3744,9 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym, if (kind_expr) { /* Try simplification even for LEN expressions. */ + bool ok; gfc_resolve_expr (kind_expr); - gfc_simplify_expr (kind_expr, 1); + ok =3D gfc_simplify_expr (kind_expr, 1); /* Variable expressions seem to default to BT_PROCEDURE. TODO find out why this is and fix it. */ if (kind_expr->ts.type !=3D BT_INTEGER @@ -3748,6 +3757,12 @@ gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym, gfc_basic_typename (kind_expr->ts.type)); goto error_return; } + if (kind_expr->ts.type =3D=3D BT_INTEGER && !ok) + { + gfc_error ("The parameter expression at %C does not " + "simplify to an INTEGER constant"); + goto error_return; + } tail->expr =3D gfc_copy_expr (kind_expr); }=