gfc_error_check ();
}
else
- /* If the type is not set already, we set it here to the
- implicit default type. It is not allowed to set it
- later to any other type. */
- gfc_set_default_type (sym, 0, gfc_current_ns);
+ {
+ /* Before the symbol is given an implicit type, check to
+ see if the symbol is already available in the namespace,
+ possibly through host association. Importantly, the
+ symbol may be a user defined type. */
+
+ gfc_symbol *tmp;
+
+ gfc_find_symbol (sym->name, NULL, 1, &tmp);
+ if (tmp && tmp->attr.generic
+ && (tmp = gfc_find_dt_in_generic (tmp)))
+ {
+ if (tmp->attr.flavor == FL_DERIVED)
+ {
+ gfc_error ("Derived type %qs at %L conflicts with "
+ "namelist object %qs at %C",
+ tmp->name, &tmp->declared_at, sym->name);
+ goto error;
+ }
+ }
+
+ /* Set type of the symbol to its implicit default type. It is
+ not allowed to set it later to any other type. */
+ gfc_set_default_type (sym, 0, gfc_current_ns);
+ }
}
if (sym->attr.in_namelist == 0
&& !gfc_add_in_namelist (&sym->attr, sym->name, NULL))
gfc_current_ns = gfc_build_block_ns (ns);
m = gfc_match (" %n => %e", name, &expr2);
+
if (m == MATCH_YES)
{
+ /* If expr2 corresponds to an implicitly typed variable, then the
+ actual type of the variable may not have been set. Set it here. */
+ if (!gfc_current_ns->seen_implicit_none
+ && expr2->expr_type == EXPR_VARIABLE
+ && expr2->ts.type == BT_UNKNOWN
+ && expr2->symtree && expr2->symtree->n.sym)
+ {
+ gfc_set_default_type (expr2->symtree->n.sym, 0, gfc_current_ns);
+ expr2->ts.type = expr2->symtree->n.sym->ts.type;
+ }
+
expr1 = gfc_get_expr ();
expr1->expr_type = EXPR_VARIABLE;
expr1->where = expr2->where;