[fortran, patch] PR25094 - check for private types in public interfaces
Jerry DeLisle
jvdelisle@verizon.net
Tue Jul 3 02:15:00 GMT 2007
Daniel Franke wrote:
> As is, gfortran accepts PRIVATE procedures in PUBLIC interfaces which expect
> dummy arguments of PRIVATE type. The patch is straightforward, the testcase
> the reporter's.
>
>
> :ADDPATCH fortran:
>
> gcc/fortran:
> 2007-07-02 Daniel Franke <franke.daniel@gmail.com>
>
> PR fortran/25094
> * resolve.c (resolve_fl_procedure): Added check for PRIVATE types
> in PUBLIC interfaces.
>
> gcc/testsuite:
> 2007-07-02 Daniel Franke <franke.daniel@gmail.com>
>
> PR fortran/25094
> * gfortran.dg/interface_13.f90: New test.
>
>
> Regression tested on i686-pc-linux-gnu. Ok for trunk?
>
> Regards
> Daniel
>
>
> ------------------------------------------------------------------------
>
> Index: fortran/resolve.c
> ===================================================================
> --- fortran/resolve.c (revision 126214)
> +++ fortran/resolve.c (working copy)
> @@ -6591,6 +6603,8 @@
> && sym->ns->parent->proc_name->attr.flavor == FL_MODULE)
> && gfc_check_access(sym->attr.access, sym->ns->default_access))
> {
> + gfc_interface *iface;
> +
> for (arg = sym->formal; arg; arg = arg->next)
> {
> if (arg->sym
> @@ -6608,6 +6622,29 @@
> return FAILURE;
> }
> }
> +
> + /* PUBLIC interfaces may expose PRIVATE procedures that take takes
> + PRIVAT to the containing module. */
"take" repeated twice in comment above and s/PRIVAT/PRIVATE/
> + for (iface = sym->generic; iface; iface = iface->next)
> + {
> + for (arg = iface->sym->formal; arg; arg = arg->next)
> + {
> + if (arg->sym
> + && arg->sym->ts.type == BT_DERIVED
> + && !arg->sym->ts.derived->attr.use_assoc
> + && !gfc_check_access (arg->sym->ts.derived->attr.access,
> + arg->sym->ts.derived->ns->default_access))
> + {
> + gfc_error_now ("Procedure '%s' in PUBLIC interface '%s' at %L takes "
> + "dummy arguments of '%s' which is PRIVATE",
> + iface->sym->name, sym->name, &iface->sym->declared_at,
> + gfc_typename(&arg->sym->ts));
> + /* Stop this message from recurring. */
> + arg->sym->ts.derived->attr.access = ACCESS_PUBLIC;
I presume you get multiple error messages. Would it be better to just break
out of the loop?
> + return FAILURE;
> + }
> + }
> + }
> }
>
---- snip -----
Regards,
Jerry
More information about the Gcc-patches
mailing list