This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: BLOCK DATA ?
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: Salvatore Filippone <sfilippone at uniroma2 dot it>
- Cc: fortran at gcc dot gnu dot org
- Date: Mon, 30 Aug 2004 14:17:27 +0200
- Subject: Re: BLOCK DATA ?
- References: <1093864861.2750.4.camel@euler>
Salvatore Filippone wrote:
> Hi there,
> The attached snippet of code produces the following:
> $ /usr/local/gfortran/bin/gfortran tst.f -o tst
> /tmp/ccjM1xsk.s: Assembler messages:
> /tmp/ccjM1xsk.s:14: Error: symbol `_BLOCK_DATA____' is already defined
>
Below patch fixes this, by appending a unique serial number to the assembler
name of every BLOCK DATA block.
Of course this only makes sense, if there's a reason why we don't use the
BLOCK DATA's name in the first place. I assume 'SUBROUTINE a' and 'BLOCK DATA
a' should collide; the frontend doesn't allow them if they're in the same
file, and I assume it would be a quality of implementation issue to also not
allow them if they're not in the same file, i.e. by having the linker giving
an error.
Built and tested. I also verified that Salvatore's testcase works now.
- Tobi
Index: parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/parse.c,v
retrieving revision 1.17
diff -u -p -r1.17 parse.c
--- parse.c 17 Aug 2004 15:34:09 -0000 1.17
+++ parse.c 30 Aug 2004 12:02:13 -0000
@@ -1062,8 +1062,12 @@ accept_statement (gfc_statement st)
{
gfc_symbol *block_data = NULL;
symbol_attribute attr;
+ static int serial = 0;
+ char name[GFC_MAX_SYMBOL_LEN+1];
- gfc_get_symbol ("_BLOCK_DATA__", gfc_current_ns, &block_data);
+ snprintf (name, GFC_MAX_SYMBOL_LEN, "_BLOCK_DATA_%d", serial++);
+
+ gfc_get_symbol (name, gfc_current_ns, &block_data);
gfc_clear_attr (&attr);
attr.flavor = FL_PROCEDURE;
attr.proc = PROC_UNKNOWN;