===================================================================
@@ -2840,7 +2840,7 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int im
if (ts->kind != -1)
{
gfc_get_ha_symbol (name, &sym);
- if (sym->generic && gfc_find_symbol (dt_name, NULL, 0, &dt_sym))
+ if (sym->generic && gfc_get_symbol (dt_name, NULL, &dt_sym))
{
gfc_error ("Type name %qs at %C is ambiguous", name);
return MATCH_ERROR;
@@ -2850,10 +2850,11 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int im
}
else if (ts->kind == -1)
{
- int iface = gfc_state_stack->previous->state != COMP_INTERFACE
- || gfc_current_ns->has_import_set;
- gfc_find_symbol (name, NULL, iface, &sym);
- if (sym && sym->generic && gfc_find_symbol (dt_name, NULL, 1, &dt_sym))
+ gfc_get_ha_symbol (name, &sym);
+ if (sym == NULL || sym->gfc_new)
+ return MATCH_NO;
+
+ if (sym && sym->generic && gfc_get_ha_symbol (dt_name, &dt_sym))
{
gfc_error ("Type name %qs at %C is ambiguous", name);
return MATCH_ERROR;
@@ -2862,8 +2863,6 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int im
dt_sym = gfc_find_dt_in_generic (sym);
ts->kind = 0;
- if (sym == NULL)
- return MATCH_NO;
}
if ((sym->attr.flavor != FL_UNKNOWN
@@ -2885,12 +2884,13 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int im
&& !gfc_add_function (&sym->attr, sym->name, NULL))
return MATCH_ERROR;
- if (!dt_sym)
+ if (!dt_sym || dt_sym->gfc_new)
{
gfc_interface *intr, *head;
/* Use upper case to save the actual derived-type symbol. */
- gfc_get_symbol (dt_name, NULL, &dt_sym);
+ if (!dt_sym)
+ gfc_get_symbol (dt_name, NULL, &dt_sym);
dt_sym->name = gfc_get_string (sym->name);
head = sym->generic;
intr = gfc_get_interface ();