From patchwork Fri Aug 30 19:25:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1979192 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwSmq6zsnz1yfX for ; Sat, 31 Aug 2024 05:26:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5CF8A384F01B for ; Fri, 30 Aug 2024 19:26:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id 47FCC385E011 for ; Fri, 30 Aug 2024 19:25:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 47FCC385E011 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 47FCC385E011 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=116.202.254.214 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725045933; cv=none; b=mxfOET0GjmwsnlI6ktissWzoMvnAWZPL3ANle0EjsYaRgBEmuiMc0hrJCqvQuTvCuOWp0ImIeqfX5WBok82BN8e9AcSvjmcu8M514SN5TQSrI67C7F0aU0jNklymQIzyKXtPb3mRi5nGQvWtfZNW5J10LMY54ZaZqWUsnuVmLws= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725045933; c=relaxed/simple; bh=VVBW3cOGa7pFOa0KOUMfkqjYe5RDkXjO+rgzEp3jKmY=; h=To:From:Subject:Date:Message-ID:Mime-Version; b=Akqi5DDDF5TwCzZUWfq0It372MJrgzRNzavnl2k3xBgdEHu5wUVizlLoNBCrHbtJo61NYofx5FMlRDe+jdM48i9ielgzm5R8HVlDybb4fiEvcb3zuCgOuIUfwz8CNnhdjDBNLBB8oG5aWNEqF08EBwtKIu0ZPms0NKyd3N43iiw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1sk7FS-0003Hs-7D for gcc-patches@gcc.gnu.org; Fri, 30 Aug 2024 21:25:30 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-patches@gcc.gnu.org From: Harald Anlauf Subject: [PATCH] Fortran: downgrade use associated namelist group name to, legacy extension Date: Fri, 30 Aug 2024 21:25:23 +0200 Message-ID: References: <64b3746d-f0b9-4150-baea-639db2dba2cc@gmx.de> Mime-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US In-Reply-To: Cc: fortran@gcc.gnu.org X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi Steve, all, the attached patch downgrades this feature from a GNU extension (silent per default) to a legacy extension (warning by default). The feature is tested in at least 4 gfortran testcases. I adjusted the pattern of one of these tests to check for the downgrade. Regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald On 8/30/24 18:33, Steve Kargl wrote: > On Thu, Aug 29, 2024 at 10:05:35PM +0200, Harald Anlauf wrote: >> >> Am 29.08.24 um 21:53 schrieb Steve Kargl: >>> Thanks for the patch. If you have not already opened a new PR for the >>> other issue with C8107, I'll open one later today. It's likely that >>> we need to check the namelist-group-name for USE association in >>> match.cc:gfc_match_namelist. >>> >>> Hmmm, it seems we already catch the error, but accept it as an >>> extension. >>> >>> % gfcx -o z -std=f2023 a.f90 && ./z >>> a.f90:11:23: >>> >>> 11 | namelist /nam_nml1/j >>> | 1 >>> Error: GNU Extension: Namelist group name 'nam_nml1' at (1) already >>> is USE associated and cannot be respecified. >> >> ah, I overlooked this. >> >>> >>> In hindsight, I wish GNU extensions had warnings associated with them. >>> >> >> Should we downgrade this extension to GFC_STD_LEGACY? > > I would support such a downgrade. In fact, I would > support making -std=f2023 the default, but that might > be pushing my luck. > >> Not sure when it was implemented or where it was used. > > 'git blame' shows the code was last touch in 2011. > I suspect that it is much older. > From 083b1f73c61eb008b37067241ec85d4c6f419f5e Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Fri, 30 Aug 2024 21:15:43 +0200 Subject: [PATCH] Fortran: downgrade use associated namelist group name to legacy extension The Fortran standard disallows use associated names as namelist group name (e.g. F2003:C581, but also later standards). This feature is a gfortran legacy extension, and we should give a warning even for -std=gnu. gcc/fortran/ChangeLog: * match.cc (gfc_match_namelist): Downgrade feature from GNU to legacy extension. gcc/testsuite/ChangeLog: * gfortran.dg/pr88169_3.f90: Adjust pattern. --- gcc/fortran/match.cc | 4 +++- gcc/testsuite/gfortran.dg/pr88169_3.f90 | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index d30a98f48fa..53c54c1c489 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -5603,9 +5603,11 @@ gfc_match_namelist (void) return MATCH_ERROR; } + /* A use associated name shall not be used as a namelist group name + (e.g. F2003:C581). It is only supported as a legacy extension. */ if (group_name->attr.flavor == FL_NAMELIST && group_name->attr.use_assoc - && !gfc_notify_std (GFC_STD_GNU, "Namelist group name %qs " + && !gfc_notify_std (GFC_STD_LEGACY, "Namelist group name %qs " "at %C already is USE associated and can" "not be respecified.", group_name->name)) return MATCH_ERROR; diff --git a/gcc/testsuite/gfortran.dg/pr88169_3.f90 b/gcc/testsuite/gfortran.dg/pr88169_3.f90 index 6bc24ed6b71..49ef430e664 100644 --- a/gcc/testsuite/gfortran.dg/pr88169_3.f90 +++ b/gcc/testsuite/gfortran.dg/pr88169_3.f90 @@ -10,6 +10,5 @@ program main use foo_nml, only: bar => foo, x implicit none real a - namelist /bar/a ! { dg-error "already is USE associated" } + namelist /bar/a ! { dg-error "Legacy Extension: .* already is USE associated" } end program -! { dg-final { cleanup-modules "foo_nml" } } -- 2.35.3