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. */
+ 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;