]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: downgrade use associated namelist group name to legacy extension
authorHarald Anlauf <anlauf@gmx.de>
Fri, 30 Aug 2024 19:15:43 +0000 (21:15 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Sat, 31 Aug 2024 14:23:38 +0000 (16:23 +0200)
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
gcc/testsuite/gfortran.dg/pr88169_3.f90

index d30a98f48fa85402b092531fde61b8cae52e8d1c..53c54c1c4899d4742bd3d6da4ea9b4d0cd6da1a0 100644 (file)
@@ -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;
index 6bc24ed6b7190d002fe7e996677e5245fe5af88c..49ef430e6640d16ecf94935c054221f6d1d4073e 100644 (file)
@@ -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" } }