This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/54221] Explicit private access specifier signals "unexpected defined but not used [-Wunused-function]" warning


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54221

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-08-10 15:35:40 UTC ---
I think there are two issues:

a) There is a bogus warning. I think that's a middle-end bug

b) The same warning should be triggered for "PRIVATE" and for "PRIVATE ::
hello_integer"

However, the Fortran front end only checks sym->attr.access == ACCESS_PRIVATE,
which obviously doesn't get set by "PRIVATE". (See patch below.) That's a
missed-optimization issue.


Simplified example (compile with -Wall or -Wunused-function):

module mod_say_hello
    private :: hello_integer
contains
    subroutine say_hello()
        call hello_integer(123)
    end subroutine say_hello
    subroutine hello_integer( a )
        integer, intent(in) ::  a
        print *, "Hello ", a, "!"
    end subroutine hello_integer
end module mod_say_hello


Patch for issue (b):

--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1841,2 +1841,9 @@ build_function_decl (gfc_symbol * sym, bool global)

+  if (sym->attr.access == ACCESS_UNKNOWN
+      && sym->ns->proc_name && sym->ns->proc_name->attr.flavor == FL_MODULE
+      && (sym->ns->default_access == ACCESS_PRIVATE
+         || (sym->ns->default_access == ACCESS_UNKNOWN
+             && gfc_option.flag_module_private)))
+    sym->attr.access = ACCESS_PRIVATE;
+
   if (!current_function_decl


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]