This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, fortran] PR34858, PR33375 - properly undo temporary symbols from common blocks
- From: Daniel Franke <franke dot daniel at gmail dot com>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Cc: hongjiu dot lu at intel dot com
- Date: Thu, 24 Jan 2008 21:25:02 +0100
- Subject: [patch, fortran] PR34858, PR33375 - properly undo temporary symbols from common blocks
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date:user-agent:cc:mime-version:content-type:message-id; bh=Ti9idMgtCECNc6tLTbHQVoOZhahkGiie1qWsLErC6Yc=; b=Ly166k79tStvpx3H8nsxkXgHkB3eeBHQduiOjk+xmDqPs7jXGfM7GhAYZQ/U+bYQQP1PkoNSmlW4fJWWCjJUM3s8w0zvTDKO23tGcnKeTh4Ne+M241Rj+dW+D+IhVUnBwYZLPZfpNC+AGnttanfXh8dmEH8n2W41gf/nayEsuKM=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:mime-version:content-type:message-id; b=tx5cKCAw/dRRDP883NdLD99b450m8b3H+SOfAz+JVA1HgQVWGAGfznEeDpHYyKkGAyc/PtMtLIWgs/JY+QsHwgr7yQ08wZSszZRcx6nZFFhQ7pyESqg3gHPAiCaP0gywDp/pIlj7BI3sk+59Xi0bKDQ+UHaKXxYoUkLWMe9vTS0=
PR34858, an error-recovery issue, turned out to be the same as PR33375
(regression in gfortran.dg/common_6.f90) which was assumed fixed. This patch
reverts the previous patch and properly resets changes in common blocks
instead.
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.
Regression tested without regressions on intel-darwin9 by Dominique and
i686-pc-linux-gnu by me. Ok for trunk?
Regards
Daniel
Index: symbol.c
===================================================================
--- symbol.c (revision 131693)
+++ symbol.c (working copy)
@@ -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)
{
Index: gfortran.h
===================================================================
--- gfortran.h (revision 131693)
+++ gfortran.h (working copy)
@@ -2137,7 +2137,6 @@ int gfc_symbols_could_alias (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: match.c
===================================================================
--- match.c (revision 131693)
+++ match.c (working copy)
@@ -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: