This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix ICE on functions with no explicit nor implicit type(PR fortran/21729)


Jakub Jelinek wrote:
> 2005-05-24  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR fortran/21729
> 	* resolve.c (resolve_contained_fntype): Use sym->attr.untyped
> 	to avoid giving error multiple times.
> 	(resolve_entries): Don't error about BT_UNKNOWN here.
> 	(resolve_unknown_f): Capitalize IMPLICIT for consistency.
> 	(gfc_resolve): Issue error if function or its entries have
> 	no explicit nor implicit type.

Ok, but I have one question about the following hunk.  I'd also prefer if you
made that hunk a function which is then called from gfc_resolve to stay in
line with the concept that gfc_resolve outlines the operations necessary for
resolution.

> @@ -4835,6 +4842,39 @@ gfc_resolve (gfc_namespace * ns)
>  
>    gfc_traverse_ns (ns, resolve_symbol);
>  
> +  if (ns->proc_name && ns->proc_name->attr.function)
> +    {
> +      gfc_entry_list *el;
> +      gfc_symbol *sym;
> +
> +      if (ns->entries)
> +	sym = ns->entries->sym;
> +      else
> +	sym = ns->proc_name;

Why this if?  Did you run into a bug when you tried to resolve the function
symbol itself?

> +      if (sym->result == sym
> +	  && sym->ts.type == BT_UNKNOWN
> +	  && gfc_set_default_type (sym, 0, NULL) == FAILURE
> +	  && !sym->attr.untyped)
> +	{
> +	  gfc_error ("Function '%s' at %L has no IMPLICIT type",
> +		     sym->name, &sym->declared_at);
> +	  sym->attr.untyped = 1;
> +	}
> +      if (ns->entries)
> +	for (el = ns->entries->next; el; el = el->next)
> +	  {
> +	    if (el->sym->result == el->sym
> +		&& el->sym->ts.type == BT_UNKNOWN
> +		&& gfc_set_default_type (el->sym, 0, NULL) == FAILURE
> +		&& !el->sym->attr.untyped)
> +	      {
> +		gfc_error ("ENTRY '%s' at %L has no IMPLICIT type",
> +			   el->sym->name, &el->sym->declared_at);
> +		el->sym->attr.untyped = 1;
> +	      }
> +	  }
> +    }
> +
>    for (n = ns->contained; n; n = n->sibling)
>      {
>        if (gfc_pure (ns->proc_name) && !gfc_pure (n->proc_name))

Thanks,
- Tobi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]