public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] PR 54224: [4.8 Regression] Bogus -Wunused-function warning with static function
@ 2012-10-19 14:50 Janus Weil
  2012-10-19 16:18 ` Tobias Burnus
  0 siblings, 1 reply; 3+ messages in thread
From: Janus Weil @ 2012-10-19 14:50 UTC (permalink / raw)
  To: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 749 bytes --]

Hi all,

this regression is haunting me a lot in real-world code. It's 'just' a
bogus warning, but it can really swamp the output for modules with
many private procedures.

I have found a fix that is rather trivial in the sense that it's a
one-liner. However, it may not be as trivial conceptually (in
particular I'm not 100% sure what caused this regression in the first
place; it might have been the the commit for PR40973).

Anyway, it regtests cleanly and fixes the problem as advertised. Ok for trunk?

Cheers,
Janus


2012-10-19  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/54224
	* trans-expr.c (conv_function_val): Set TREE_USED.

2012-10-19  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/54224
	* gfortran.dg/warn_unused_function.f90: New.

[-- Attachment #2: pr54224.diff --]
[-- Type: application/octet-stream, Size: 467 bytes --]

Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c	(revision 192611)
+++ gcc/fortran/trans-expr.c	(working copy)
@@ -2674,6 +2674,8 @@ conv_function_val (gfc_se * se, gfc_symbol * sym,
       if (!sym->backend_decl)
 	sym->backend_decl = gfc_get_extern_function_decl (sym);
 
+      TREE_USED (sym->backend_decl) = 1;
+
       tmp = sym->backend_decl;
 
       if (sym->attr.cray_pointee)

[-- Attachment #3: warn_unused_function.f90 --]
[-- Type: application/octet-stream, Size: 518 bytes --]

! { dg-do compile }
! { dg-options "-Wunused-function" }
!
! PR 54224: [4.8 Regression] Bogus -Wunused-function warning with static function
!
! Contributed by Tobias Burnus <burnus@gcc.gnu.org>

module mod_say_hello
    private :: hello_integer
contains
    subroutine say_hello()
        call hello_integer(123)
    end subroutine

    subroutine hello_integer( a )
        integer, intent(in) ::  a
        print *, "Hello ", a, "!"
    end subroutine
end module

! { dg-final { cleanup-modules "mod_say_hello" } }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran] PR 54224: [4.8 Regression] Bogus -Wunused-function warning with static function
  2012-10-19 14:50 [Patch, Fortran] PR 54224: [4.8 Regression] Bogus -Wunused-function warning with static function Janus Weil
@ 2012-10-19 16:18 ` Tobias Burnus
  2012-10-19 18:02   ` Janus Weil
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2012-10-19 16:18 UTC (permalink / raw)
  To: Janus Weil; +Cc: gfortran, gcc-patches

Hi Janus,

Janus Weil wrote:
> I have found a fix that is rather trivial in the sense that it's a
> one-liner.

I think it is the proper fix.

> However, it may not be as trivial conceptually (in particular I'm not 100% sure what caused this regression in the first place

I think it is the combination of having "static" noninternal procedures 
(which is a new 4.8 feature) combined with the middle-end assumption 
that the FE marks procedures as TREE_USED. (The ME does mark them as 
TREE_USED, but too late.)

(The other question is why the diagnostic doesn't work for internal 
procedures - or for GNU C's nested function. I think also for module 
variables such a diagnostic would be useful. However, both are just 
missed diagnostics and not diagnostic-output regressions.)

> Anyway, it regtests cleanly and fixes the problem as advertised. Ok for trunk?

Yes. Thanks for the patch.

Tobias

> 2012-10-19  Janus Weil  <janus@gcc.gnu.org>
>
> 	PR fortran/54224
> 	* trans-expr.c (conv_function_val): Set TREE_USED.
>
> 2012-10-19  Janus Weil  <janus@gcc.gnu.org>
>
> 	PR fortran/54224
> 	* gfortran.dg/warn_unused_function.f90: New.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran] PR 54224: [4.8 Regression] Bogus -Wunused-function warning with static function
  2012-10-19 16:18 ` Tobias Burnus
@ 2012-10-19 18:02   ` Janus Weil
  0 siblings, 0 replies; 3+ messages in thread
From: Janus Weil @ 2012-10-19 18:02 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gfortran, gcc-patches

Hi Tobias,

>> I have found a fix that is rather trivial in the sense that it's a
>> one-liner.
>
>
> I think it is the proper fix.

good :)


>> However, it may not be as trivial conceptually (in particular I'm not 100%
>> sure what caused this regression in the first place
>
>
> I think it is the combination of having "static" noninternal procedures
> (which is a new 4.8 feature) combined with the middle-end assumption that
> the FE marks procedures as TREE_USED. (The ME does mark them as TREE_USED,
> but too late.)
>
> (The other question is why the diagnostic doesn't work for internal
> procedures - or for GNU C's nested function. I think also for module
> variables such a diagnostic would be useful. However, both are just missed
> diagnostics and not diagnostic-output regressions.)

these things we should follow-up on in the PR, or are there other PRs for these?


>> Anyway, it regtests cleanly and fixes the problem as advertised. Ok for
>> trunk?
>
>
> Yes. Thanks for the patch.

Thanks. Committed as r192620.

Cheers,
Janus

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-19 17:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-19 14:50 [Patch, Fortran] PR 54224: [4.8 Regression] Bogus -Wunused-function warning with static function Janus Weil
2012-10-19 16:18 ` Tobias Burnus
2012-10-19 18:02   ` Janus Weil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).