From 083b1f73c61eb008b37067241ec85d4c6f419f5e Mon Sep 17 00:00:00 2001
From: Harald Anlauf <anlauf@gmx.de>
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(-)
@@ -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;
@@ -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