This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Support ENTRY in FUNCTIONs (PR fortran/13082) (take 2)
Jakub Jelinek wrote:
> + /* Otherwise the result will be passed through an union by
> + reference. */
> + proc->attr.mixed_entry_master = 1;
> + for (el = ns->entries; el; el = el->next)
> + if ((sym = el->sym->result)->attr.dimension
> + || sym->attr.pointer
> + || (sym->ts.type != BT_INTEGER
> + && sym->ts.type != BT_REAL
> + && sym->ts.type != BT_COMPLEX
> + && sym->ts.type != BT_LOGICAL)
> + || (sym->ts.kind != gfc_default_integer_kind
> + && sym->ts.kind != gfc_default_real_kind
> + && sym->ts.kind != gfc_default_double_kind
> + && sym->ts.kind != gfc_default_complex_kind
> + && sym->ts.kind != gfc_default_logical_kind))
This logic is flawed. You need to check
((sym->ts.type == BT_INTEGER && sym->ts.kind != gfc_default_integer_kind)
|| ((sym->ts.type == BT_REAL || sym->ts.type == BT_COMPLEX)
&& sym->ts.kind != gfc_default_real_kind)
|| (sym->ts.type == BT_REAL && sym->ts.kind != gfc_default_double_kind)
|| (sym->ts.type == BT_LOGICAL && sym->ts.kind != gfc_default_logical_kind))
etc. to determine if the type / kind combination is allowed, otherwise e.g.
INTEGER*8 will slip through.
> + {
> + gfc_error ("Characteristics of ENTRY results is not the same");
> + gfc_error ("and not scalar non-POINTER either in '%s' at %L",
> + sym->name,
> + &sym->declared_at);
A better error message would probably be
if (sym->attr.dimension)
gfc_error ("ENTRY result %s can't be an array in FUNCTION %s at %L",
sym->name, ns->proc_name->name, &sym->declared_at);
else if (sym->attr.pointer)
gfc_error ("ENTRY result %s can't be a POINTER in FUNCTION %s at %L",
sym->name, ns->proc_name->name, &sym->declared_at);
else
gfc_error ("ENTRY result %s can't be of type %s in FUNCTION %s at %L",
sym->name, gfc_typename (sym->ts), &sym->declared_at);
Other than that this is ok for mainline and 4.0 unless Paul B. sees something
that I missed, as he does at times :-)
Thanks,
- Tobi