Harald,

I'm fine with the patch.  You may want to wait to see
if anyone has a rasonable objection.

-- 
steve

On Fri, Aug 30, 2024 at 09:25:23PM +0200, Harald Anlauf wrote:
> 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 <anl...@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(-)
> 
> 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
> 


-- 
Steve

Reply via email to