]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/29537 (ICE in gfc_match_common for blank common in BLOCK DATA unit)
authorBernhard Fischer <aldot@gcc.gnu.org>
Tue, 31 Oct 2006 23:38:58 +0000 (00:38 +0100)
committerBernhard Reutner-Fischer <aldot@gcc.gnu.org>
Tue, 31 Oct 2006 23:38:58 +0000 (00:38 +0100)
fortran/ChangeLog:
2006-11-01  Bernhard Fischer  <aldot@gcc.gnu.org>

        PR fortran/29537
        * trans-common.c (gfc_trans_common): If the blank common is
        in a procedure or program without a name then proc_name is null, so use
        the locus of the common.
        (gfc_sym_mangled_common_id): Fix whitespace.
        * match.c (gfc_match_common): Emit warning about blank common in
        block data.

testsuite/ChangeLog:
2006-11-01  Bernhard Fischer  <aldot@gcc.gnu.org>

        PR fortran/29537
        * gfortran.dg/blockdata_1.f90: Add warning about blank common in block
data.
        * gfortran.dg/blockdata_2.f90: New testcase.

From-SVN: r118347

gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/fortran/trans-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/blockdata_1.f90
gcc/testsuite/gfortran.dg/blockdata_2.f90 [new file with mode: 0644]

index 84804f944697450c5d60f0db87190bc990f1fb73..e9ba75fe3b4b2eb6ce38c061869a073f28c419dc 100644 (file)
@@ -1,3 +1,13 @@
+2006-11-01  Bernhard Fischer  <aldot@gcc.gnu.org>
+
+       PR fortran/29537
+       * trans-common.c (gfc_trans_common): If the blank common is
+       in a procedure or program without a name then proc_name is null, so
+       use the locus of the common.
+       (gfc_sym_mangled_common_id): Fix whitespace.
+       * match.c (gfc_match_common): Emit warning about blank common in
+       block data.
+
 2006-10-31  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        PR fortran/29067
index 3f393856798e10118608e8649acbb7a7798a76a5..5012c3588ee368fce1295439d76049a063cb308a 100644 (file)
@@ -2327,16 +2327,19 @@ gfc_match_common (void)
 
       if (name[0] == '\0')
        {
+         if (gfc_current_ns->is_block_data)
+           {
+             gfc_warning ("BLOCK DATA unit cannot contain blank COMMON at %C");
+           }
          t = &gfc_current_ns->blank_common;
          if (t->head == NULL)
            t->where = gfc_current_locus;
-         head = &t->head;
        }
       else
        {
          t = gfc_get_common (name, 0);
-         head = &t->head;
        }
+      head = &t->head;
 
       if (*head == NULL)
        tail = NULL;
index 5350eacdef05c14f6fb7e304ea747938b9cd655c..83da32f52347aa9d1b41c2426fb5882f9ffb1909 100644 (file)
@@ -219,7 +219,7 @@ add_segments (segment_info *list, segment_info *v)
 /* Construct mangled common block name from symbol name.  */
 
 static tree
-gfc_sym_mangled_common_id (const char  *name)
+gfc_sym_mangled_common_id (const char *name)
 {
   int has_underscore;
   char mangled_name[GFC_MAX_MANGLED_SYMBOL_LEN + 1];
@@ -1054,13 +1054,18 @@ gfc_trans_common (gfc_namespace *ns)
   if (ns->blank_common.head != NULL)
     {
       c = gfc_get_common_head ();
+
       /* We've lost the real location, so use the location of the
         enclosing procedure.  */
-      c->where = ns->proc_name->declared_at;
+      if (ns->proc_name != NULL)
+       c->where = ns->proc_name->declared_at;
+      else
+       c->where = ns->blank_common.head->common_head->where;
+
       strcpy (c->name, BLANK_COMMON_NAME);
       translate_common (c, ns->blank_common.head);
     }
+
   /* Translate all named common blocks.  */
   gfc_traverse_symtree (ns->common_root, named_common);
 
index f6f95b3159092f2ea02ee7f37b84129d1d0cc7ef..12e6d5d58a0b2b3bd86b524c575c33e3c209fb6a 100644 (file)
@@ -1,3 +1,10 @@
+2006-11-01  Bernhard Fischer  <aldot@gcc.gnu.org>
+
+       PR fortran/29537
+       * gfortran.dg/blockdata_1.f90: Add warning about blank common in block
+       data.
+       * gfortran.dg/blockdata_2.f90: New testcase.
+
 2006-10-31  Thomas Koenig  <Thomas.Koenig@online.de>
 
        PR libfortran/29627
index 5c475f1d0f4ed1c5eb3f6e493657c86da5edd38f..81cd02cc90b5d9ece62d151670823f2cd06bba8d 100644 (file)
@@ -14,7 +14,7 @@ end blockdata d1
 
 block data d2
  common /b/ u
- common j
+ common j ! { dg-warning "cannot contain blank COMMON" }
  data j /1/
 end block data d2
 !
diff --git a/gcc/testsuite/gfortran.dg/blockdata_2.f90 b/gcc/testsuite/gfortran.dg/blockdata_2.f90
new file mode 100644 (file)
index 0000000..a1370c8
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! Test for pr29537 where we did ICE trying to dereference the NULL
+! proc_name from an unnamed block data which we intended to use as locus
+! for a blank common.
+block data
+  common c ! { dg-warning "cannot contain blank COMMON" }
+end !block data
+end