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.
This commit is contained in:
Harald Anlauf 2024-08-30 21:15:43 +02:00
parent afd9558b94
commit 79b5b50402
2 changed files with 4 additions and 3 deletions

View 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;

View 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" } }