mirror of git://gcc.gnu.org/git/gcc.git
gfortran.h (gfc_symbol): Add pointer to next derived type.
2018-07-20 Andrew Benson <abenson@carnegiescience.edu> * gfortran.h (gfc_symbol): Add pointer to next derived type. (gfc_dt_list, gfc_get_dt_list): Remove. (gfc_namespace): Replace gfc_dt_list with gfc_symbol. * parse.c (resolve_all_program_units): Replace gfc_free_dt_list() with simple nullification of gfc_derived_types. * resolve.c (resolve_global_procedure): Replace gfc_dt_list with gfc_symbol. (add_dt_to_dt_list): Change derived type linked list insertion to utilize dt_next pointers in gfc_symbol. * symbol.c (gfc_new_symbol, gfc_free_dt_list, gfc_symbol_done2) (get_iso_c_binding_dt, generate_isocbinding_symbol): Remove gfc_free_dt_list as gfc_dt_list is obsoleted. Change derived type linked list search/insertion to utilize dt_next pointers in gfc_symbol. * trans-types.c (gfc_get_derived_type): Change derived type linked list search to utilize dt_next pointers in gfc_symbol. From-SVN: r262909
This commit is contained in:
parent
d9a81cdb41
commit
20e8ceae67
|
|
@ -1,3 +1,21 @@
|
||||||
|
2018-07-20 Andrew Benson <abenson@carnegiescience.edu>
|
||||||
|
|
||||||
|
* gfortran.h (gfc_symbol): Add pointer to next derived type.
|
||||||
|
(gfc_dt_list, gfc_get_dt_list): Remove.
|
||||||
|
(gfc_namespace): Replace gfc_dt_list with gfc_symbol.
|
||||||
|
* parse.c (resolve_all_program_units): Replace gfc_free_dt_list() with
|
||||||
|
simple nullification of gfc_derived_types.
|
||||||
|
* resolve.c (resolve_global_procedure): Replace gfc_dt_list with
|
||||||
|
gfc_symbol.
|
||||||
|
(add_dt_to_dt_list): Change derived type linked list insertion to
|
||||||
|
utilize dt_next pointers in gfc_symbol.
|
||||||
|
* symbol.c (gfc_new_symbol, gfc_free_dt_list, gfc_symbol_done2)
|
||||||
|
(get_iso_c_binding_dt, generate_isocbinding_symbol): Remove
|
||||||
|
gfc_free_dt_list as gfc_dt_list is obsoleted. Change derived type
|
||||||
|
linked list search/insertion to utilize dt_next pointers in gfc_symbol.
|
||||||
|
* trans-types.c (gfc_get_derived_type): Change derived type linked
|
||||||
|
list search to utilize dt_next pointers in gfc_symbol.
|
||||||
|
|
||||||
2018-07-19 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
|
2018-07-19 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
|
||||||
|
|
||||||
* trans-intrinsic.c: (gfc_conv_intrinsic_minmax): Emit MIN_MAX_EXPR
|
* trans-intrinsic.c: (gfc_conv_intrinsic_minmax): Emit MIN_MAX_EXPR
|
||||||
|
|
|
||||||
|
|
@ -1614,6 +1614,9 @@ typedef struct gfc_symbol
|
||||||
|
|
||||||
/* Link to corresponding association-list if this is an associate name. */
|
/* Link to corresponding association-list if this is an associate name. */
|
||||||
struct gfc_association_list *assoc;
|
struct gfc_association_list *assoc;
|
||||||
|
|
||||||
|
/* Link to next entry in derived type list */
|
||||||
|
struct gfc_symbol *dt_next;
|
||||||
}
|
}
|
||||||
gfc_symbol;
|
gfc_symbol;
|
||||||
|
|
||||||
|
|
@ -1715,18 +1718,8 @@ typedef struct gfc_symtree
|
||||||
}
|
}
|
||||||
gfc_symtree;
|
gfc_symtree;
|
||||||
|
|
||||||
/* A linked list of derived types in the namespace. */
|
/* A list of all derived types. */
|
||||||
typedef struct gfc_dt_list
|
extern gfc_symbol *gfc_derived_types;
|
||||||
{
|
|
||||||
struct gfc_symbol *derived;
|
|
||||||
struct gfc_dt_list *next;
|
|
||||||
}
|
|
||||||
gfc_dt_list;
|
|
||||||
|
|
||||||
#define gfc_get_dt_list() XCNEW (gfc_dt_list)
|
|
||||||
|
|
||||||
/* A list of all derived types. */
|
|
||||||
extern gfc_dt_list *gfc_derived_types;
|
|
||||||
|
|
||||||
typedef struct gfc_oacc_routine_name
|
typedef struct gfc_oacc_routine_name
|
||||||
{
|
{
|
||||||
|
|
@ -1812,7 +1805,7 @@ typedef struct gfc_namespace
|
||||||
|
|
||||||
gfc_charlen *cl_list;
|
gfc_charlen *cl_list;
|
||||||
|
|
||||||
gfc_dt_list *derived_types;
|
gfc_symbol *derived_types;
|
||||||
|
|
||||||
int save_all, seen_save, seen_implicit_none;
|
int save_all, seen_save, seen_implicit_none;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6051,7 +6051,7 @@ add_global_program (void)
|
||||||
static void
|
static void
|
||||||
resolve_all_program_units (gfc_namespace *gfc_global_ns_list)
|
resolve_all_program_units (gfc_namespace *gfc_global_ns_list)
|
||||||
{
|
{
|
||||||
gfc_free_dt_list ();
|
gfc_derived_types = NULL;
|
||||||
gfc_current_ns = gfc_global_ns_list;
|
gfc_current_ns = gfc_global_ns_list;
|
||||||
for (; gfc_current_ns; gfc_current_ns = gfc_current_ns->sibling)
|
for (; gfc_current_ns; gfc_current_ns = gfc_current_ns->sibling)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2509,7 +2509,7 @@ resolve_global_procedure (gfc_symbol *sym, locus *where,
|
||||||
/* Resolve the gsymbol namespace if needed. */
|
/* Resolve the gsymbol namespace if needed. */
|
||||||
if (!gsym->ns->resolved)
|
if (!gsym->ns->resolved)
|
||||||
{
|
{
|
||||||
gfc_dt_list *old_dt_list;
|
gfc_symbol *old_dt_list;
|
||||||
|
|
||||||
/* Stash away derived types so that the backend_decls do not
|
/* Stash away derived types so that the backend_decls do not
|
||||||
get mixed up. */
|
get mixed up. */
|
||||||
|
|
@ -13533,16 +13533,19 @@ resolve_typebound_procedures (gfc_symbol* derived)
|
||||||
static void
|
static void
|
||||||
add_dt_to_dt_list (gfc_symbol *derived)
|
add_dt_to_dt_list (gfc_symbol *derived)
|
||||||
{
|
{
|
||||||
gfc_dt_list *dt_list;
|
if (!derived->dt_next)
|
||||||
|
{
|
||||||
for (dt_list = gfc_derived_types; dt_list; dt_list = dt_list->next)
|
if (gfc_derived_types)
|
||||||
if (derived == dt_list->derived)
|
{
|
||||||
return;
|
derived->dt_next = gfc_derived_types->dt_next;
|
||||||
|
gfc_derived_types->dt_next = derived;
|
||||||
dt_list = gfc_get_dt_list ();
|
}
|
||||||
dt_list->next = gfc_derived_types;
|
else
|
||||||
dt_list->derived = derived;
|
{
|
||||||
gfc_derived_types = dt_list;
|
derived->dt_next = derived;
|
||||||
|
}
|
||||||
|
gfc_derived_types = derived;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ gfc_namespace *gfc_global_ns_list;
|
||||||
|
|
||||||
gfc_gsymbol *gfc_gsym_root = NULL;
|
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 default_undo_chgset_var = { vNULL, vNULL, NULL };
|
||||||
static gfc_undo_change_set *latest_undo_chgset = &default_undo_chgset_var;
|
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->common_block = NULL;
|
||||||
p->f2k_derived = NULL;
|
p->f2k_derived = NULL;
|
||||||
p->assoc = NULL;
|
p->assoc = NULL;
|
||||||
|
p->dt_next = NULL;
|
||||||
p->fn_result_spec = 0;
|
p->fn_result_spec = 0;
|
||||||
|
|
||||||
return p;
|
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. */
|
/* Free the gfc_equiv_info's. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -4098,7 +4082,7 @@ gfc_symbol_done_2 (void)
|
||||||
gfc_free_namespace (gfc_current_ns);
|
gfc_free_namespace (gfc_current_ns);
|
||||||
gfc_current_ns = NULL;
|
gfc_current_ns = NULL;
|
||||||
}
|
}
|
||||||
gfc_free_dt_list ();
|
gfc_derived_types = NULL;
|
||||||
|
|
||||||
enforce_single_undo_checkpoint ();
|
enforce_single_undo_checkpoint ();
|
||||||
free_undo_change_set_data (*latest_undo_chgset);
|
free_undo_change_set_data (*latest_undo_chgset);
|
||||||
|
|
@ -4361,20 +4345,21 @@ gfc_get_gsymbol (const char *name)
|
||||||
static gfc_symbol *
|
static gfc_symbol *
|
||||||
get_iso_c_binding_dt (int sym_id)
|
get_iso_c_binding_dt (int sym_id)
|
||||||
{
|
{
|
||||||
gfc_dt_list *dt_list;
|
gfc_symbol *dt_list = gfc_derived_types;
|
||||||
|
|
||||||
dt_list = gfc_derived_types;
|
|
||||||
|
|
||||||
/* Loop through the derived types in the name list, searching for
|
/* Loop through the derived types in the name list, searching for
|
||||||
the desired symbol from iso_c_binding. Search the parent namespaces
|
the desired symbol from iso_c_binding. Search the parent namespaces
|
||||||
if necessary and requested to (parent_flag). */
|
if necessary and requested to (parent_flag). */
|
||||||
while (dt_list != NULL)
|
if (dt_list)
|
||||||
{
|
{
|
||||||
if (dt_list->derived->from_intmod != INTMOD_NONE
|
while (dt_list->dt_next != gfc_derived_types)
|
||||||
&& dt_list->derived->intmod_sym_id == sym_id)
|
{
|
||||||
return dt_list->derived;
|
if (dt_list->from_intmod != INTMOD_NONE
|
||||||
|
&& dt_list->intmod_sym_id == sym_id)
|
||||||
|
return dt_list;
|
||||||
|
|
||||||
dt_list = dt_list->next;
|
dt_list = dt_list->dt_next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
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
|
if (tmp_sym->attr.flavor == FL_DERIVED
|
||||||
&& !get_iso_c_binding_dt (tmp_sym->intmod_sym_id))
|
&& !get_iso_c_binding_dt (tmp_sym->intmod_sym_id))
|
||||||
{
|
{
|
||||||
gfc_dt_list *dt_list;
|
if (gfc_derived_types)
|
||||||
dt_list = gfc_get_dt_list ();
|
{
|
||||||
dt_list->derived = tmp_sym;
|
tmp_sym->dt_next = gfc_derived_types->dt_next;
|
||||||
dt_list->next = gfc_derived_types;
|
gfc_derived_types->dt_next = tmp_sym;
|
||||||
gfc_derived_types = dt_list;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmp_sym->dt_next = tmp_sym;
|
||||||
|
}
|
||||||
|
gfc_derived_types = tmp_sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmp_symtree;
|
return tmp_symtree;
|
||||||
|
|
@ -4892,7 +4882,6 @@ generate_isocbinding_symbol (const char *mod_name, iso_c_binding_symbol s,
|
||||||
case ISOCBINDING_FUNPTR:
|
case ISOCBINDING_FUNPTR:
|
||||||
{
|
{
|
||||||
gfc_symbol *dt_sym;
|
gfc_symbol *dt_sym;
|
||||||
gfc_dt_list **dt_list_ptr = NULL;
|
|
||||||
gfc_component *tmp_comp = NULL;
|
gfc_component *tmp_comp = NULL;
|
||||||
|
|
||||||
/* Generate real derived type. */
|
/* 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;
|
dt_sym->ts.u.derived = dt_sym;
|
||||||
|
|
||||||
/* Add the symbol created for the derived type to the current ns. */
|
/* Add the symbol created for the derived type to the current ns. */
|
||||||
dt_list_ptr = &(gfc_derived_types);
|
if (gfc_derived_types)
|
||||||
while (*dt_list_ptr != NULL && (*dt_list_ptr)->next != NULL)
|
{
|
||||||
dt_list_ptr = &((*dt_list_ptr)->next);
|
dt_sym->dt_next = gfc_derived_types->dt_next;
|
||||||
|
gfc_derived_types->dt_next = dt_sym;
|
||||||
/* 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. */
|
else
|
||||||
if (*dt_list_ptr != NULL)
|
{
|
||||||
dt_list_ptr = &((*dt_list_ptr)->next);
|
dt_sym->dt_next = dt_sym;
|
||||||
(*dt_list_ptr) = gfc_get_dt_list ();
|
}
|
||||||
(*dt_list_ptr)->derived = dt_sym;
|
gfc_derived_types = dt_sym;
|
||||||
(*dt_list_ptr)->next = NULL;
|
|
||||||
|
|
||||||
gfc_add_component (dt_sym, "c_address", &tmp_comp);
|
gfc_add_component (dt_sym, "c_address", &tmp_comp);
|
||||||
if (tmp_comp == NULL)
|
if (tmp_comp == NULL)
|
||||||
|
|
|
||||||
|
|
@ -2542,7 +2542,6 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen)
|
||||||
bool got_canonical = false;
|
bool got_canonical = false;
|
||||||
bool unlimited_entity = false;
|
bool unlimited_entity = false;
|
||||||
gfc_component *c;
|
gfc_component *c;
|
||||||
gfc_dt_list *dt;
|
|
||||||
gfc_namespace *ns;
|
gfc_namespace *ns;
|
||||||
tree tmp;
|
tree tmp;
|
||||||
bool coarray_flag;
|
bool coarray_flag;
|
||||||
|
|
@ -2607,14 +2606,19 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen)
|
||||||
ns->translated && !got_canonical;
|
ns->translated && !got_canonical;
|
||||||
ns = ns->sibling)
|
ns = ns->sibling)
|
||||||
{
|
{
|
||||||
dt = ns->derived_types;
|
if (ns->derived_types)
|
||||||
for (; dt && !canonical; dt = dt->next)
|
|
||||||
{
|
{
|
||||||
gfc_copy_dt_decls_ifequal (dt->derived, derived, true);
|
for (gfc_symbol *dt = ns->derived_types; dt && !got_canonical;
|
||||||
if (derived->backend_decl)
|
dt = dt->dt_next)
|
||||||
got_canonical = true;
|
{
|
||||||
}
|
gfc_copy_dt_decls_ifequal (dt, derived, true);
|
||||||
}
|
if (derived->backend_decl)
|
||||||
|
got_canonical = true;
|
||||||
|
if (dt->dt_next == ns->derived_types)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store up the canonical type to be added to this one. */
|
/* Store up the canonical type to be added to this one. */
|
||||||
|
|
@ -2875,8 +2879,12 @@ copy_derived_types:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (dt = gfc_derived_types; dt; dt = dt->next)
|
for (gfc_symbol *dt = gfc_derived_types; dt; dt = dt->dt_next)
|
||||||
gfc_copy_dt_decls_ifequal (derived, dt->derived, false);
|
{
|
||||||
|
gfc_copy_dt_decls_ifequal (derived, dt, false);
|
||||||
|
if (dt->dt_next == gfc_derived_types)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return derived->backend_decl;
|
return derived->backend_decl;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue