]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/33375 (ICE (segfault) gfortran.dg/common_6.f90)
authorDaniel Franke <franke.daniel@gmail.com>
Thu, 24 Jan 2008 21:36:14 +0000 (16:36 -0500)
committerDaniel Franke <dfranke@gcc.gnu.org>
Thu, 24 Jan 2008 21:36:14 +0000 (16:36 -0500)
2008-01-24  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/33375
        PR fortran/34858
        * gfortran.h: Revert changes from 2008-01-17.
        * match.c: Likewise.
        * symbol.c: Likewise.
        (gfc_undo_symbols): Undo namespace changes related to common blocks.

From-SVN: r131811

gcc/fortran/ChangeLog
gcc/fortran/gfortran.h
gcc/fortran/match.c
gcc/fortran/symbol.c

index c9cdfde362e313d7cf33ca8f7782a6634a7aab79..8d705f8e97f9683a9349a2da80f7015890d4ae5c 100644 (file)
@@ -1,3 +1,12 @@
+2008-01-24  Daniel Franke  <franke.daniel@gmail.com>
+
+       PR fortran/33375
+       PR fortran/34858
+       * gfortran.h: Revert changes from 2008-01-17.
+       * match.c: Likewise.
+       * symbol.c: Likewise.
+       (gfc_undo_symbols): Undo namespace changes related to common blocks.
+
 2008-01-24  Daniel Franke  <franke.daniel@gmail.com>
 
        PR fortran/34202
index d5f00737d3db4dba6e9b0692cddb0f6832fc20a4..aac1f821334c0f184350c6cfa1d7e761eb3b01aa 100644 (file)
@@ -2137,7 +2137,6 @@ int gfc_symbols_could_alias (gfc_symbol *, gfc_symbol *);
 void gfc_undo_symbols (void);
 void gfc_commit_symbols (void);
 void gfc_commit_symbol (gfc_symbol *);
-void gfc_free_common_tree (gfc_symtree *);
 void gfc_free_namespace (gfc_namespace *);
 
 void gfc_symbol_init_2 (void);
index f21748c1b9ae4cdd395a9a1a4b5fd952209c00c6..ad636f93f3d6709e8a25a65e4914251f2dce7589 100644 (file)
@@ -2951,8 +2951,6 @@ done:
   return MATCH_YES;
 
 syntax:
-  gfc_free_common_tree (gfc_current_ns->common_root);
-  gfc_current_ns->common_root = NULL;
   gfc_syntax_error (ST_COMMON);
 
 cleanup:
index a50ed261141c014a87adbf1d4d56be220d259697..a802fa16dc8c05000432fc42c1f0c46aad23a9f7 100644 (file)
@@ -2582,6 +2582,33 @@ gfc_undo_symbols (void)
       if (p->new)
        {
          /* Symbol was new.  */
+         if (p->attr.in_common && p->common_block->head)
+           {
+             /* If the symbol was added to any common block, it
+                needs to be removed to stop the resolver looking
+                for a (possibly) dead symbol.  */
+
+             if (p->common_block->head == p)
+               p->common_block->head = p->common_next;
+             else
+               {
+                 gfc_symbol *cparent, *csym;
+
+                 cparent = p->common_block->head;
+                 csym = cparent->common_next;
+
+                 while (csym != p)
+                   {
+                     cparent = csym;
+                     csym = csym->common_next;
+                   }
+
+                 gcc_assert(cparent->common_next == p);
+
+                 cparent->common_next = csym->common_next;
+               }
+           }
+
          delete_symtree (&p->ns->sym_root, p->name);
 
          p->refs--;
@@ -2726,14 +2753,14 @@ gfc_commit_symbol (gfc_symbol *sym)
 /* Recursive function that deletes an entire tree and all the common
    head structures it points to.  */
 
-void
-gfc_free_common_tree (gfc_symtree * common_tree)
+static void
+free_common_tree (gfc_symtree * common_tree)
 {
   if (common_tree == NULL)
     return;
 
-  gfc_free_common_tree (common_tree->left);
-  gfc_free_common_tree (common_tree->right);
+  free_common_tree (common_tree->left);
+  free_common_tree (common_tree->right);
 
   gfc_free (common_tree);
 }  
@@ -2863,7 +2890,7 @@ gfc_free_namespace (gfc_namespace *ns)
 
   free_sym_tree (ns->sym_root);
   free_uop_tree (ns->uop_root);
-  gfc_free_common_tree (ns->common_root);
+  free_common_tree (ns->common_root);
 
   for (cl = ns->cl_list; cl; cl = cl2)
     {