From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from imap2.colo.codethink.co.uk (imap2.colo.codethink.co.uk [78.40.148.184]) by sourceware.org (Postfix) with ESMTPS id A5887386EC49; Fri, 2 Oct 2020 05:51:06 +0000 (GMT) Authentication-Results: sourceware.org; dmarc=permerror header.from=codethink.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=mark.eggleston@codethink.co.uk Received: from [90.196.211.77] (helo=[192.168.0.10]) by imap2.colo.codethink.co.uk with esmtpsa (Exim 4.92 #3 (Debian)) id 1kODyB-0006lZ-F1; Fri, 02 Oct 2020 06:51:04 +0100 To: gcc-patches , fortran From: Mark Eggleston Subject: [PATCH] Fortran : ICE in gfc_validate_kind PR96099 Message-ID: <0ae4999a-3814-7e25-705c-23058c6c3ecf@codethink.co.uk> Date: Fri, 2 Oct 2020 06:51:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------900899E7505FE2CE9E10B156" Content-Language: en-US X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2020 05:51:08 -0000 This is a multi-part message in MIME format. --------------900899E7505FE2CE9E10B156 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit This is a follow up to PR95586 which fixed only the ICE that occurred when using derived types in an implicit statement.  The ICE occurred because an attempt was made to determine kind for types that do not have kinds. This patch ensures that kind is only determined for types that support kind. OK for master? Is it worth backporting? [PATCH] Fortran  : ICE in gfc_validate_kind PR96099 Only check for kind if the type supports kind. 2020-10-02  Mark Eggleston /gcc/fortran     PR fortran/96099     * decl.c (gfc_match_implicit): Check for numeric and logical     types. 2020-10-02  Mark Eggleston /gcc/testsuite     PR fortran/96099     * gfortran.dg/pr96099_1.f90: New test.     * gfortran.dg/pr96099_2.f90: New test. -- https://www.codethink.co.uk/privacy.html --------------900899E7505FE2CE9E10B156 Content-Type: text/x-patch; charset=UTF-8; name="0001-Fortran-ICE-in-gfc_validate_kind-PR96099.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Fortran-ICE-in-gfc_validate_kind-PR96099.patch" >From 8770d2c3f599f8e758747b606613ae53f0b26bc9 Mon Sep 17 00:00:00 2001 From: Mark Eggleston Date: Thu, 1 Oct 2020 11:14:09 +0100 Subject: [PATCH] Fortran : ICE in gfc_validate_kind PR96099 Only check for kind if the type supports kind. 2020-10-02 Mark Eggleston /gcc/fortran PR fortran/96099 * decl.c (gfc_match_implicit): Check for numeric and logical types. 2020-10-02 Mark Eggleston /gcc/testsuite PR fortran/96099 * gfortran.dg/pr96099_1.f90: New test. * gfortran.dg/pr96099_2.f90: New test. --- gcc/fortran/decl.c | 2 +- gcc/testsuite/gfortran.dg/pr96099_1.f90 | 8 ++++++++ gcc/testsuite/gfortran.dg/pr96099_2.f90 | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/pr96099_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr96099_2.f90 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 326e6f5db7a..bddf69cce19 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -4835,7 +4835,7 @@ gfc_match_implicit (void) /* Last chance -- check (). */ if (ts.type == BT_CHARACTER) m = gfc_match_char_spec (&ts); - else if (ts.type != BT_DERIVED) + else if (gfc_numeric_ts(&ts) || ts.type == BT_LOGICAL) { m = gfc_match_kind_spec (&ts, false); if (m == MATCH_NO) diff --git a/gcc/testsuite/gfortran.dg/pr96099_1.f90 b/gcc/testsuite/gfortran.dg/pr96099_1.f90 new file mode 100644 index 00000000000..9754bd39dfc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr96099_1.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } + +program pr96099_1 + implicit class(t) (1) ! { dg-error "Syntax error in IMPLICIT" } + type t + end type +end + diff --git a/gcc/testsuite/gfortran.dg/pr96099_2.f90 b/gcc/testsuite/gfortran.dg/pr96099_2.f90 new file mode 100644 index 00000000000..3136d2ef377 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr96099_2.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } + +program pr96099_2 + integer n1 + parameter (n1 = 1) + implicit class(t) (n1) ! { dg-error "Syntax error in IMPLICIT" } + type t + end type +end -- 2.11.0 --------------900899E7505FE2CE9E10B156--