This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, fortran] PR30481 Accepts namelist-group object with assumed character length
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Fortran List <fortran at gcc dot gnu dot org>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 22 Jan 2007 18:53:51 -0800
- Subject: [patch, fortran] PR30481 Accepts namelist-group object with assumed character length
Hi,
The attached patch developed by Paul Thomas adds a check for assumed size
character variables in namelist and issues an error.
I have reviewed and regression tested with make -k check-fortran on
x86-64-linux-gnu.
I plan to commit this for Paul within a day or so to trunk and then to 4.2 in a
few more days.
Regards,
Jerry
2007-01-22 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30481
* match.c (gfc_match_namelist): Add check for assumed size character
in namelist and provide error if found.
Index: match.c
===================================================================
*** match.c (revision 121074)
--- match.c (working copy)
*************** gfc_match_namelist (void)
*** 2591,2597 ****
&& gfc_add_in_namelist (&sym->attr, sym->name, NULL) == FAILURE)
goto error;
! /* Use gfc_error_check here, rather than goto error, so that this
these are the only errors for the next two lines. */
if (sym->as && sym->as->type == AS_ASSUMED_SIZE)
{
--- 2591,2597 ----
&& gfc_add_in_namelist (&sym->attr, sym->name, NULL) == FAILURE)
goto error;
! /* Use gfc_error_check here, rather than goto error, so that
these are the only errors for the next two lines. */
if (sym->as && sym->as->type == AS_ASSUMED_SIZE)
{
*************** gfc_match_namelist (void)
*** 2600,2605 ****
--- 2600,2612 ----
gfc_error_check ();
}
+ if (sym->ts.type == BT_CHARACTER && sym->ts.cl->length == NULL)
+ {
+ gfc_error ("Assumed character length '%s' in namelist '%s' at "
+ "%C is not allowed", sym->name, group_name->name);
+ gfc_error_check ();
+ }
+
if (sym->as && sym->as->type == AS_ASSUMED_SHAPE
&& gfc_notify_std (GFC_STD_GNU, "Assumed shape array '%s' in "
"namelist '%s' at %C is an extension.",
! { dg-do compile }
! PR30481 Assumed size character is not allowed in namelist.
! Test case from PR, submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>
subroutine foo(c)
character*(*) c
namelist /abc/ c ! { dg-error "Assumed character length" }
end subroutine