diff options
Diffstat (limited to 'gcc/fortran/symbol.c')
-rw-r--r-- | gcc/fortran/symbol.c | 78 |
1 files changed, 33 insertions, 45 deletions
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index b4a950a..0a4f7c1 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -107,7 +107,7 @@ gfc_namespace *gfc_global_ns_list; gfc_gsymbol *gfc_gsym_root = NULL; -gfc_dt_list *gfc_derived_types; +gfc_symbol *gfc_derived_types; static gfc_undo_change_set default_undo_chgset_var = { vNULL, vNULL, NULL }; static gfc_undo_change_set *latest_undo_chgset = &default_undo_chgset_var; @@ -3137,6 +3137,7 @@ gfc_new_symbol (const char *name, gfc_namespace *ns) p->common_block = NULL; p->f2k_derived = NULL; p->assoc = NULL; + p->dt_next = NULL; p->fn_result_spec = 0; return p; @@ -3896,23 +3897,6 @@ free_sym_tree (gfc_symtree *sym_tree) } -/* Free the derived type list. */ - -void -gfc_free_dt_list (void) -{ - gfc_dt_list *dt, *n; - - for (dt = gfc_derived_types; dt; dt = n) - { - n = dt->next; - free (dt); - } - - gfc_derived_types = NULL; -} - - /* Free the gfc_equiv_info's. */ static void @@ -4098,7 +4082,7 @@ gfc_symbol_done_2 (void) gfc_free_namespace (gfc_current_ns); gfc_current_ns = NULL; } - gfc_free_dt_list (); + gfc_derived_types = NULL; enforce_single_undo_checkpoint (); free_undo_change_set_data (*latest_undo_chgset); @@ -4361,20 +4345,21 @@ gfc_get_gsymbol (const char *name) static gfc_symbol * get_iso_c_binding_dt (int sym_id) { - gfc_dt_list *dt_list; - - dt_list = gfc_derived_types; + gfc_symbol *dt_list = gfc_derived_types; /* Loop through the derived types in the name list, searching for the desired symbol from iso_c_binding. Search the parent namespaces if necessary and requested to (parent_flag). */ - while (dt_list != NULL) + if (dt_list) { - if (dt_list->derived->from_intmod != INTMOD_NONE - && dt_list->derived->intmod_sym_id == sym_id) - return dt_list->derived; - - dt_list = dt_list->next; + while (dt_list->dt_next != gfc_derived_types) + { + if (dt_list->from_intmod != INTMOD_NONE + && dt_list->intmod_sym_id == sym_id) + return dt_list; + + dt_list = dt_list->dt_next; + } } return NULL; @@ -4780,11 +4765,16 @@ generate_isocbinding_symbol (const char *mod_name, iso_c_binding_symbol s, if (tmp_sym->attr.flavor == FL_DERIVED && !get_iso_c_binding_dt (tmp_sym->intmod_sym_id)) { - gfc_dt_list *dt_list; - dt_list = gfc_get_dt_list (); - dt_list->derived = tmp_sym; - dt_list->next = gfc_derived_types; - gfc_derived_types = dt_list; + if (gfc_derived_types) + { + tmp_sym->dt_next = gfc_derived_types->dt_next; + gfc_derived_types->dt_next = tmp_sym; + } + else + { + tmp_sym->dt_next = tmp_sym; + } + gfc_derived_types = tmp_sym; } return tmp_symtree; @@ -4892,7 +4882,6 @@ generate_isocbinding_symbol (const char *mod_name, iso_c_binding_symbol s, case ISOCBINDING_FUNPTR: { gfc_symbol *dt_sym; - gfc_dt_list **dt_list_ptr = NULL; gfc_component *tmp_comp = NULL; /* Generate real derived type. */ @@ -4954,17 +4943,16 @@ generate_isocbinding_symbol (const char *mod_name, iso_c_binding_symbol s, dt_sym->ts.u.derived = dt_sym; /* Add the symbol created for the derived type to the current ns. */ - dt_list_ptr = &(gfc_derived_types); - while (*dt_list_ptr != NULL && (*dt_list_ptr)->next != NULL) - dt_list_ptr = &((*dt_list_ptr)->next); - - /* There is already at least one derived type in the list, so append - the one we're currently building for c_ptr or c_funptr. */ - if (*dt_list_ptr != NULL) - dt_list_ptr = &((*dt_list_ptr)->next); - (*dt_list_ptr) = gfc_get_dt_list (); - (*dt_list_ptr)->derived = dt_sym; - (*dt_list_ptr)->next = NULL; + if (gfc_derived_types) + { + dt_sym->dt_next = gfc_derived_types->dt_next; + gfc_derived_types->dt_next = dt_sym; + } + else + { + dt_sym->dt_next = dt_sym; + } + gfc_derived_types = dt_sym; gfc_add_component (dt_sym, "c_address", &tmp_comp); if (tmp_comp == NULL) |