summaryrefslogtreecommitdiff
path: root/gcc/fortran/symbol.c
diff options
context:
space:
mode:
authormikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-03 17:21:07 +0000
committermikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-03 17:21:07 +0000
commit2ba401fca88d1237b6c3a892aee630054581e589 (patch)
tree201285fb373f7d395c832998ebe9b214142841b5 /gcc/fortran/symbol.c
parenta2dcff194ecea59c6d79e8be42220694d2bc4a6b (diff)
downloadgcc-2ba401fca88d1237b6c3a892aee630054581e589.tar.gz
fortran/
* symbol.c (gfc_undo_symbols): Move code... (restore_old_symbol): ... here as a new function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196412 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/symbol.c')
-rw-r--r--gcc/fortran/symbol.c111
1 files changed, 60 insertions, 51 deletions
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index 1bf4c86e1f1..ce39b8cf427 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -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.
This subroutine is made simpler due to the fact that attributes are
never removed once added. */
@@ -2886,7 +2944,7 @@ find_common_symtree (gfc_symtree *st, gfc_common_head *head)
void
gfc_undo_symbols (void)
{
- gfc_symbol *p, *old;
+ gfc_symbol *p;
unsigned i;
FOR_EACH_VEC_ELT (latest_undo_chgset->syms, i, p)
@@ -2945,58 +3003,9 @@ gfc_undo_symbols (void)
gfc_delete_symtree (&p->ns->sym_root, p->name);
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
- {
- 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;
+ restore_old_symbol (p);
}
latest_undo_chgset->syms.truncate (0);