Hello world,

the attached patch makes block names unique, so that
-fdump-fortran-original dumps are easier to read.

Regression-tested. OK for trunk?

        Thomas

2011-04-22  Thomas Koenig  <tkoe...@gcc.gnu.org>

        * decl.c (gfc_match_end):  Check that the block name starts
        with "block@".
        * parse.c (gfc_build_block_ns):  Make block names unique by
        numbering them.
Index: decl.c
===================================================================
--- decl.c	(Revision 172856)
+++ decl.c	(Arbeitskopie)
@@ -5746,7 +5746,7 @@ gfc_match_end (gfc_statement *st)
     {
     case COMP_ASSOCIATE:
     case COMP_BLOCK:
-      if (!strcmp (block_name, "block@"))
+      if (!strncmp (block_name, "block@", strlen("block@")))
 	block_name = NULL;
       break;
 
Index: parse.c
===================================================================
--- parse.c	(Revision 172856)
+++ parse.c	(Arbeitskopie)
@@ -3135,6 +3135,7 @@ gfc_namespace*
 gfc_build_block_ns (gfc_namespace *parent_ns)
 {
   gfc_namespace* my_ns;
+  static int numblock = 1;
 
   my_ns = gfc_get_namespace (parent_ns, 1);
   my_ns->construct_entities = 1;
@@ -3149,8 +3150,10 @@ gfc_build_block_ns (gfc_namespace *parent_ns)
   else
     {
       gfc_try t;
+      char buffer[20];  /* Enough to hold "block@2147483648\n".  */
 
-      gfc_get_symbol ("block@", my_ns, &my_ns->proc_name);
+      snprintf(buffer, sizeof(buffer), "block@%d", numblock++);
+      gfc_get_symbol (buffer, my_ns, &my_ns->proc_name);
       t = gfc_add_flavor (&my_ns->proc_name->attr, FL_LABEL,
 			  my_ns->proc_name->name, NULL);
       gcc_assert (t == SUCCESS);

Reply via email to