From patchwork Sun Oct 24 19:00:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 46577 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A7283858413 for ; Sun, 24 Oct 2021 19:01:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A7283858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635102115; bh=7urSC3LDGreBZHc5WYZoO8//H6Tm3t2vgqkijxkI2sU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=as7PzidyxZlPf3jtzWNFcJI1ITdvloGyufwlv2RzOrGCKBPRYuuRP8bWHGcA9QcYl MKcz6qpmPXgBjq9JmI5MeW+pSx1DGJ08zAjPOs0ONp2WSVnFfDqQYc4rlAiIom0l7h I6J9itlMlyxW6QfG0z3WPXFvgxs9xeYAFo1aJ1OI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by sourceware.org (Postfix) with ESMTPS id 030B63858D3C; Sun, 24 Oct 2021 19:01:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 030B63858D3C X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [79.251.11.37] ([79.251.11.37]) by web-mail.gmx.net (3c-app-gmx-bap61.server.lan [172.19.172.131]) (via HTTP); Sun, 24 Oct 2021 21:00:52 +0200 MIME-Version: 1.0 Message-ID: To: Steve Kargl Subject: [PATCH] PR fortran/102917 - PDT type parameters are not restricted to default integer Date: Sun, 24 Oct 2021 21:00:52 +0200 Importance: normal Sensitivity: Normal In-Reply-To: <20211022202523.GA55664@troutmask.apl.washington.edu> References: <20211022193538.GA98810@troutmask.apl.washington.edu> <20211022202523.GA55664@troutmask.apl.washington.edu> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:8GF+rFPhsYc+2mq73iSRkmvE4Gi2MY8NreLqSIZQrP+CPQFxKsArtwS51oq6DsyB7emU/ 9Pk4+W/TV30lj78m85GTVoP1tRZGOqaojcpkYYEaTqsLN86/tzKC+orM56m02IEwaSOSZgBzFalw frkVekUaprCWEuEuoC7POgQeiPAK/ysJtula4TVVK8PlRzGxeUoGoJgGCTQaV6BX1fye9xBPlDeE PX/oe8aGRE4E8WnDzJnwwQYjMNt+qMjlIIoKfaBW5H55uVtYXOTGpKXzifHwXUq3gxor3kdZwEBU ro= X-UI-Out-Filterresults: notjunk:1;V03:K0:9L2zjuJuWNE=:Ct8ez4S7ECHJR0PtjltnH+ 0wySX6ghelzBnIZJWXd2G8Son186UFRDH3btSgahuzKO3yGR3oRQt4QSGNFqredoS1ajBDkNL 7tf7/7jeHCFuIH6ttEOeuG1zF+pvFCF0sByZUqunzkSMSBbgF/yQAiNLkQybaa/E8ZwvoJjYV p0mUE2HoVxvmA5ojmtyOquESB7AQAhvHDvwDxXELKbl/vKePhJRMhhKt7IuamZSJ0Vuf7Jj7p sAZuySiptq3KAsUEexcPbO/Y7MZ4+Zhq++SbPLcFpe+cpaBPC6EuWdqCQSFJcFHtkWt//kSXH 44XtdJWot3MMGr0k0V/rzQX3jcE3q6qO8MdgEnizmYiHuCuy4pbhBRd8uLcjosvUl8fSq4MN2 t6+aabwf1sa3XmQb4ov9pK9uM6ozA9PkJgfNYOIqA5jZ5g2YSk72K11hgzdz8Z9BLElvNjeUj 8TpfAJZA0G2Y5e49J4M+QXNhkp7jxHkpWpOsexDy9YzR0PUKysHMR+GNjgpFrLZzGczAZv4/r 1fUke2j1DVEAA5rHO+NXVV0d1RO0uAEQoon3PfJ5h+kEmfaAXx03Hz8J2pmY8ix4H5s4TE3sJ 6oEiZIXt4/0XtQEQtejFGHC1BWcufwDweNm3uYW7YKAcjpeuobo3cf+rCFmpjtpkN1PF5aKYk wojly+Z+Dm9zfiPiJ6KNdgXVHQN5aCRFCaVBnbyjdFgsDcaDVhsVAU/7HiC2hj85m/9ZY04S6 OGPVnI7qTsF6odbAgPcbkOikNEH11cGvQoZtFE/FgWJXo9FUaZP0YPip2wTGvjRqkuoWOdTxZ /erHtXX X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Cc: gcc-patches , fortran@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Dear Fortranners, Steve, I've created PR 102917 for tracking this issue and packaged the attached patch. Regtested on x86_64-pc-linux-gnu. OK mainline? Thanks, Harald > Gesendet: Freitag, 22. Oktober 2021 um 22:25 Uhr > Von: "Steve Kargl" > An: "Harald Anlauf" > Cc: fortran@gcc.gnu.org > Betreff: Re: PDT type parameters are not restricted to default integer > > On Fri, Oct 22, 2021 at 10:16:05PM +0200, Harald Anlauf wrote: > > Hi Steve, > > > > Am 22.10.21 um 21:35 schrieb Steve Kargl via Fortran: > > > Here's an obvious quick fix. Please apply. > > > > > > > > > diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c > > > index 6043e100fbb..e889bb44142 100644 > > > --- a/gcc/fortran/decl.c > > > +++ b/gcc/fortran/decl.c > > > @@ -5619,14 +5619,6 @@ match_attr_spec (void) > > > m = MATCH_ERROR; > > > goto cleanup; > > > } > > > - if (current_ts.kind != gfc_default_integer_kind) > > > - { > > > - gfc_error ("Component with LEN attribute at %C must be " > > > - "default integer kind (%d)", > > > - gfc_default_integer_kind); > > > - m = MATCH_ERROR; > > > - goto cleanup; > > > - } > > > } > > > else > > > { > > > > I think you are right. We should always have allowed any integer kind. > > > > However, have you checked whether this change introduces regressions? > > If you don't, somebody else will. Please open a PR, then. > > > > It seems that pdt_4.f03 will fail with the above patch because > it explicitly tests for this error message. That's the only > failure in the testsuite. For the record, F2003, page 48, > > R435 type-param-def-stmt is INTEGER [ kind-selector ] , ... > > Each type parameter is itself of type integer. If its kind selector > is omitted, the kind type parameter is default integer. > > Now that I think about and look, there is a nearby similar gcc_error() > for KIND. This should be removed too. > > -- > Steve > Fortran: do not restrict PDT KIND and LEN type parameters to default integer gcc/fortran/ChangeLog: PR fortran/102917 * decl.c (match_attr_spec): Remove invalid integer kind checks on KIND and LEN attributes of PDTs. gcc/testsuite/ChangeLog: PR fortran/102917 * gfortran.dg/pdt_4.f03: Adjust testcase. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 6043e100fbb..ce61e53eb7b 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -5592,14 +5592,6 @@ match_attr_spec (void) m = MATCH_ERROR; goto cleanup; } - if (current_ts.kind != gfc_default_integer_kind) - { - gfc_error ("Component with KIND attribute at %C must be " - "default integer kind (%d)", - gfc_default_integer_kind); - m = MATCH_ERROR; - goto cleanup; - } } else if (d == DECL_LEN) { @@ -5619,14 +5611,6 @@ match_attr_spec (void) m = MATCH_ERROR; goto cleanup; } - if (current_ts.kind != gfc_default_integer_kind) - { - gfc_error ("Component with LEN attribute at %C must be " - "default integer kind (%d)", - gfc_default_integer_kind); - m = MATCH_ERROR; - goto cleanup; - } } else { diff --git a/gcc/testsuite/gfortran.dg/pdt_4.f03 b/gcc/testsuite/gfortran.dg/pdt_4.f03 index c1af65a5248..37412e4ca82 100644 --- a/gcc/testsuite/gfortran.dg/pdt_4.f03 +++ b/gcc/testsuite/gfortran.dg/pdt_4.f03 @@ -28,9 +28,9 @@ end module type :: bad_pdt (a,b, c, d) ! { dg-error "does not have a component" } real, kind :: a ! { dg-error "must be INTEGER" } - INTEGER(8), kind :: b ! { dg-error "be default integer kind" } + INTEGER(8), kind :: b real, LEN :: c ! { dg-error "must be INTEGER" } - INTEGER(8), LEN :: d ! { dg-error "be default integer kind" } + INTEGER(8), LEN :: d end type type :: mytype (a,b)