This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, fortran] PR24227 initialized symbol in COMMON: Missing checks
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Fortran List <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 25 Nov 2007 17:03:55 -0800
- Subject: [patch, fortran] PR24227 initialized symbol in COMMON: Missing checks
This patch adds back a simplified error message and checks to see if the symbol
is in BLOCK DATA or not. Allowed if -std=gnu.
Regression tested on x86-64.
OK for trunk?
Jerry
2007-11-25 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/34227
* match.c (gfc_match_common): Add additional check for BLOCK DATA.
Index: match.c
===================================================================
--- match.c (revision 130417)
+++ match.c (working copy)
@@ -2783,6 +2783,20 @@ gfc_match_common (void)
goto cleanup;
}
+ if (gfc_add_in_common (&sym->attr, sym->name, NULL) == FAILURE)
+ goto cleanup;
+
+ if (sym->value != NULL && sym->value->expr_type != EXPR_NULL
+ && (name[0] == '\0' || !sym->attr.data)
+ && gfc_current_state () != COMP_BLOCK_DATA)
+ {
+ if (gfc_notify_std (GFC_STD_GNU, "Initialized symbol '%s' at %C "
+ "can only be COMMON in "
+ "BLOCK DATA", sym->name)
+ == FAILURE)
+ goto cleanup;
+ }
+
if (gfc_add_in_common (&sym->attr, sym->name, NULL) == FAILURE)
goto cleanup;
! { dg-do compile }
! { dg-options "-std=f95" }
! PR34227 Initialized symbol in COMMON: Missing checks
program main
implicit none
integer, parameter:: nmin = 2
character(len=3) :: emname(nmin)=(/'bar','baz'/)
common/nmstr/emname ! { dg-error "can only be COMMON in BLOCK DATA" }
end program main