From patchwork Tue Oct 26 19:40:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1546612 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Q7QKACRg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hf2JL084Xz9sRN for ; Wed, 27 Oct 2021 06:41:36 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3101B385841A for ; Tue, 26 Oct 2021 19:41:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3101B385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635277294; bh=d8cGj1i6KSHBsOZjOPuXYs2UP2KeTGEArvbHUt8Or58=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Q7QKACRgE8w6b8Lk6slKqYYLsVfY39osHhoH4KnBrEolpKK/PIzTkE4OPCVXG/kDS FYNAQ9EKaAwrHx/Vb1L16SAH7BJdfdUqa9jhVcF43qQdFwSlzT3JmXaiJsovOwI16c 5jdTe2Om2ZlF/0VtzopP5CSOs7dmYGIj8GAQI9HA= 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 BBABF3858409; Tue, 26 Oct 2021 19:40:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BBABF3858409 X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [79.251.14.173] ([79.251.14.173]) by web-mail.gmx.net (3c-app-gmx-bs16.server.lan [172.19.170.68]) (via HTTP); Tue, 26 Oct 2021 21:40:32 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] PR fortran/102956 - PDT KIND and LEN type parameters are mutually exclusive Date: Tue, 26 Oct 2021 21:40:32 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:BWfiYb4qetr1X+gpxlch+4m+Dt+m190A5z3nh7WNbEtsoEclCq/iOkVwVOSp5y5JbIwnR 71jevaV834/4woO90+uXQAMQXwaMZjGbo23TB7BA7PGV+8a/WAdxtodvKKHb/f5DKJY836XJK5xs YwiVvEF8OSj1qVz449X/WQJ/BN2o4+OJRnfmOvBamaY0N+PLqongwwt6Y6470TeNxoK2rqbJgjpy i/yZpnB0g/gAbZo1wp/bVaYWL4ogikveXoMxnPwFE1lxd4FetDp5GqdgjAuHKr3WK1MKTTJoodCx lc= X-UI-Out-Filterresults: notjunk:1;V03:K0:d/KPorVnvc8=:rROPrBGqBU1VISUGVnbfG1 DYdjGFXkPU7zkBwmNxoew2oeZ59/j+O//d55lTdr6p0tfKWAxieIXhfX7QzNZuEaLV2Z1UKho X1DqPDD7RZdmIB5AbuaD+tKdRJRsx4HHLlJIkX31whK2apaguZ6U/tEVTSTNczJr4UQmEA6Rq hK+6aXvbP81UOs8jKI4vCNxmy9YHcHM6iT0VepWTyE6OmhKCGny8W5C8bIXNvWVpT7fP4C3Yy vhIpwZ54TTvNWXgCIgrS5U8CRmIaSo5A5ZYf7+c2kRs9EdTgBhllEe6uncucxE0bf7Z380bFP q5K3yNQYQUvFUPl0FbZMN2Gp50FpfFIRaFdlohlDns4kTFfR6GoS8Y0P4k5xtYH4cypggGt77 pM82c8nEnZEcEQDHwFLrpRLHXHX+UdgFTV+endxl9fSDokqSUOYecJuYddwrvh5jFvCFgjlz0 FXFvGq7P2EDNO3fnGVqfkZ+Mm80oCHo8+npWUV4uZNuISf3Y7p49o+OyZSstoLqS+psfPEB+r adtiParujNDoeGw5ABf/2Oanrz7ylw5r6EsZvYEubP9+ZU9KqYtkCSyQuq3gEUilMxwa9Fl6I 3yIdRXKq3nPA6OjgjRhXsvLJDKg5YWxRUKPfOtmbu8DL324zCrAmmOn6Gy+V80nIdK7gKfK2B dc35AIhOfrx03Ho7foPyCsoPPAbqHJ69/+/qIPdfI4wNDTweDwn0hMlPKtUboLAK6ZtbJppvC XGoaGy2StK28EjLwO+IRMIUNpMq3N5Toqd3oAin87Hp9w+uW2eyHO373GUM= X-Spam-Status: No, score=-11.3 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 Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Dear Fortranners, we were missing a conflict check for PDT KIND and LEN type parameters: F2018: 7.5.3.1 Type parameter definition statement R732 type-param-def-stmt is integer-type-spec, type-param-attr-spec :: type-param-decl-list R734 type-param-attr-spec is KIND or LEN (3) The type-param-attr-spec explicitly specifies whether a type parameter is a kind parameter or a length parameter. Thus the KIND and LEN attributes are mutually exclusive. The attached trivial patch remedies that. Regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald Fortran: [PDT] KIND and LEN type parameters are mutually exclusive gcc/fortran/ChangeLog: PR fortran/102956 * symbol.c (gfc_check_conflict): Add conflict check for PDT KIND and LEN type parameters. gcc/testsuite/ChangeLog: PR fortran/102956 * gfortran.dg/pdt_32.f03: New test. diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 2c4acd5abe1..c77f3f84962 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -720,6 +720,7 @@ gfc_check_conflict (symbol_attribute *attr, const char *name, locus *where) conf (pdt_len, pointer) conf (pdt_len, dimension) conf (pdt_len, codimension) + conf (pdt_len, pdt_kind) if (attr->access == ACCESS_PRIVATE) { diff --git a/gcc/testsuite/gfortran.dg/pdt_32.f03 b/gcc/testsuite/gfortran.dg/pdt_32.f03 new file mode 100644 index 00000000000..f8d40410828 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pdt_32.f03 @@ -0,0 +1,17 @@ +! { dg-do compile } +! PR fortran/102956 +! PDT KIND and LEN type parameters are mutually exclusive (F2018:R734) +! +module m + type :: good_pdt (k,l) + integer, kind :: k = 1 + integer, len :: l = 1 + character(kind=k,len=l) :: c + end type good_pdt + + type :: bad_pdt (k,l) ! { dg-error "does not have a component" } + integer, kind, len :: k = 1 ! { dg-error "attribute conflicts with" } + integer, len, kind :: l = 1 ! { dg-error "attribute conflicts with" } + character(kind=k,len=l) :: c ! { dg-error "has not been declared" } + end type bad_pdt +end