https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64861
Bug ID: 64861 Summary: Possible wrong code with BIND(C) and PRIVATE + slightly bogus warning Product: gcc Version: 5.0 Status: UNCONFIRMED Keywords: diagnostic, wrong-code Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org Blocks: 49111 This PR is partially identical to PR49111 / See also https://groups.google.com/forum/#!topic/comp.lang.fortran/RedeUCqh12c ("Private interfaces with iso_c_binding") In modules, gfortran warns for module procedures - and for interface procedures with BIND(C) attribute, which are marked as PRIVATE: Warning: Symbol 'my_c_routine' at (1) is marked PRIVATE but has been given the binding label 'my_c_routine' This warning seems to be on by default (not checked) and is slightly bogus. There are two meanings of PRIVATE: (a) avoid cluttering the name space when USE-ing a module. (b) To hide a symbol from the rest of the world. Fortran's meaning is (a), although some users think of (b) - seemingly also the warning writer. Additionally, there might be a wrong-code issue: gfortran marks PRIVATE module procedures (and variables) which are not otherwise used as being only used in that file - based on the knowledge that it cannot be used (without knowledge of the name mangling of gfortran). I think it currently misses the check for BIND(C). (BTW: A BIND(C) function without a name (i.e. name="" or an internal procedure) can continue to be marked as static.) THUS: * Check whether the TREE_PUBLIC handling is correctly done for BIND(C)+PRIVATE (honoring additionally whether it has a binding name or not.) The following items are the same/similar to PR49111 * Check whether the warning message makes really sense - and if so, improve the wording and consider not to enable it by default. * If continuing to warn: Consider not to warn at all for INTERFACE and only for module procedures.