Commit 718e305d by Mikael Morin

symbol.c (gfc_undo_symbols): Move code...

fortran/
	* symbol.c (gfc_undo_symbols): Move code...
	(restore_old_symbol): ... here as a new function.

From-SVN: r196412
parent dd355a42
2013-03-03 Mikael Morin <mikael@gcc.gnu.org> 2013-03-03 Mikael Morin <mikael@gcc.gnu.org>
* Make-lang.in (F95_PARSER_OBJS): Add dependency to vec.h * symbol.c (gfc_undo_symbols): Move code...
* gfortran.h: Include vec.h (restore_old_symbol): ... here as a new function.
2013-03-03 Mikael Morin <mikael@gcc.gnu.org>
* Make-lang.in (F95_PARSER_OBJS): Add dependency to vec.h.
* gfortran.h: Include vec.h.
(gfc_undo_change_set): New struct. (gfc_undo_change_set): New struct.
* symbol.c (tentative_tbp): Remove struct. * symbol.c (tentative_tbp): Remove struct.
(changed_syms, tentative_tbp_list): Remove variables. (changed_syms, tentative_tbp_list): Remove variables.
......
...@@ -2879,6 +2879,64 @@ find_common_symtree (gfc_symtree *st, gfc_common_head *head) ...@@ -2879,6 +2879,64 @@ find_common_symtree (gfc_symtree *st, gfc_common_head *head)
} }
/* Restore previous state of symbol. Just copy simple stuff. */
static void
restore_old_symbol (gfc_symbol *p)
{
gfc_symbol *old;
p->mark = 0;
old = p->old_symbol;
p->ts.type = old->ts.type;
p->ts.kind = old->ts.kind;
p->attr = old->attr;
if (p->value != old->value)
{
gfc_free_expr (old->value);
p->value = NULL;
}
if (p->as != old->as)
{
if (p->as)
gfc_free_array_spec (p->as);
p->as = old->as;
}
p->generic = old->generic;
p->component_access = old->component_access;
if (p->namelist != NULL && old->namelist == NULL)
{
gfc_free_namelist (p->namelist);
p->namelist = NULL;
}
else
{
if (p->namelist_tail != old->namelist_tail)
{
gfc_free_namelist (old->namelist_tail->next);
old->namelist_tail->next = NULL;
}
}
p->namelist_tail = old->namelist_tail;
if (p->formal != old->formal)
{
gfc_free_formal_arglist (p->formal);
p->formal = old->formal;
}
free (p->old_symbol);
p->old_symbol = NULL;
}
/* Undoes all the changes made to symbols in the current statement. /* Undoes all the changes made to symbols in the current statement.
This subroutine is made simpler due to the fact that attributes are This subroutine is made simpler due to the fact that attributes are
never removed once added. */ never removed once added. */
...@@ -2886,7 +2944,7 @@ find_common_symtree (gfc_symtree *st, gfc_common_head *head) ...@@ -2886,7 +2944,7 @@ find_common_symtree (gfc_symtree *st, gfc_common_head *head)
void void
gfc_undo_symbols (void) gfc_undo_symbols (void)
{ {
gfc_symbol *p, *old; gfc_symbol *p;
unsigned i; unsigned i;
FOR_EACH_VEC_ELT (latest_undo_chgset->syms, i, p) FOR_EACH_VEC_ELT (latest_undo_chgset->syms, i, p)
...@@ -2945,58 +3003,9 @@ gfc_undo_symbols (void) ...@@ -2945,58 +3003,9 @@ gfc_undo_symbols (void)
gfc_delete_symtree (&p->ns->sym_root, p->name); gfc_delete_symtree (&p->ns->sym_root, p->name);
gfc_release_symbol (p); gfc_release_symbol (p);
continue;
}
/* Restore previous state of symbol. Just copy simple stuff. */
p->mark = 0;
old = p->old_symbol;
p->ts.type = old->ts.type;
p->ts.kind = old->ts.kind;
p->attr = old->attr;
if (p->value != old->value)
{
gfc_free_expr (old->value);
p->value = NULL;
}
if (p->as != old->as)
{
if (p->as)
gfc_free_array_spec (p->as);
p->as = old->as;
}
p->generic = old->generic;
p->component_access = old->component_access;
if (p->namelist != NULL && old->namelist == NULL)
{
gfc_free_namelist (p->namelist);
p->namelist = NULL;
} }
else else
{ restore_old_symbol (p);
if (p->namelist_tail != old->namelist_tail)
{
gfc_free_namelist (old->namelist_tail->next);
old->namelist_tail->next = NULL;
}
}
p->namelist_tail = old->namelist_tail;
if (p->formal != old->formal)
{
gfc_free_formal_arglist (p->formal);
p->formal = old->formal;
}
free (p->old_symbol);
p->old_symbol = NULL;
} }
latest_undo_chgset->syms.truncate (0); latest_undo_chgset->syms.truncate (0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment