https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47266
Dominique d'Humieres <dominiq at lps dot ens.fr> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |WAITING Last reconfirmed| |2015-11-08 Blocks| |36854 Ever confirmed|0 |1 --- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> --- The following patch @@ -1842,7 +1843,8 @@ DECL_EXTERNAL (fndecl) = 0; if (!current_function_decl - && !sym->attr.entry_master && !sym->attr.is_main_program) + && !sym->attr.entry_master && !sym->attr.is_main_program + && (sym->attr.access != ACCESS_PRIVATE || sym->binding_label)) TREE_PUBLIC (fndecl) = 1; attributes = add_attributes_to_decl (attr, NULL_TREE); has been applied at revision r186223 (pr40973 and pr52751). Modified at r186464 (pr52916) by --- trunk/gcc/fortran/trans-decl.c 2012/04/08 07:15:01 186223 +++ trunk/gcc/fortran/trans-decl.c 2012/04/15 05:52:51 186464 @@ -1844,7 +1844,8 @@ if (!current_function_decl && !sym->attr.entry_master && !sym->attr.is_main_program - && (sym->attr.access != ACCESS_PRIVATE || sym->binding_label)) + && (sym->attr.access != ACCESS_PRIVATE || sym->binding_label + || sym->attr.public_used)) TREE_PUBLIC (fndecl) = 1; attributes = add_attributes_to_decl (attr, NULL_TREE); Thus the patch at http://gcc.gnu.org/ml/fortran/2011-01/msg00094.html no longer applies. I have tested --- ../_clean/gcc/fortran/trans-decl.c 2015-10-29 18:20:14.000000000 +0100 +++ gcc/fortran/trans-decl.c 2015-11-08 13:23:12.000000000 +0100 @@ -2075,7 +2075,7 @@ build_function_decl (gfc_symbol * sym, b if (!current_function_decl && !sym->attr.entry_master && !sym->attr.is_main_program && (sym->attr.access != ACCESS_PRIVATE || sym->binding_label - || sym->attr.public_used)) + || sym->attr.public_used || sym->binding_label[0] != '\0')) TREE_PUBLIC (fndecl) = 1; if (sym->attr.referenced || sym->attr.entry_master) but it caused a lot of regressions (ICEs). Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36854 [Bug 36854] [meta-bug] fortran front-end optimization