[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-06-30 Thread manu at gcc dot gnu dot org


--- Comment #21 from manu at gcc dot gnu dot org  2007-06-30 12:56 ---
Subject: Bug 4076

Author: manu
Date: Sat Jun 30 12:56:43 2007
New Revision: 126144

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=126144
Log:
2007-06-30  Manuel Lopez-Ibanez  [EMAIL PROTECTED]

PR c/4076
* c-typeck.c (build_external_ref): Don't mark as used if called
from itself.
* calls.c (rtx_for_function_call): Likewise.

testsuite/
* gcc.dg/Wunused-function.c: New.

Added:
trunk/gcc/testsuite/gcc.dg/Wunused-function.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-typeck.c
trunk/gcc/calls.c
trunk/gcc/testsuite/ChangeLog


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-06-30 Thread manu at gcc dot gnu dot org


--- Comment #22 from manu at gcc dot gnu dot org  2007-06-30 12:58 ---
Fixed for GCC 4.3


-- 

manu at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED
   Target Milestone|--- |4.3.0


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-06-19 Thread mrs at apple dot com


--- Comment #20 from mrs at apple dot com  2007-06-19 23:36 ---
The patch was approved today on the gcc-patches list.


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-05-19 Thread patchapp at dberlin dot org


--- Comment #19 from patchapp at dberlin dot org  2007-05-20 02:10 ---
Subject: Bug number PR4076

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-05/msg01298.html


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-04-13 Thread steven at gcc dot gnu dot org


--- Comment #17 from steven at gcc dot gnu dot org  2007-04-13 22:39 ---
Manuel has a good patch for this.  I don't know what's holding it up.


-- 

steven at gcc dot gnu dot org changed:

   What|Removed |Added

 AssignedTo|steven at gcc dot gnu dot   |unassigned at gcc dot gnu
   |org |dot org
 Status|ASSIGNED|NEW


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-04-13 Thread manu at gcc dot gnu dot org


--- Comment #18 from manu at gcc dot gnu dot org  2007-04-13 22:54 ---
(In reply to comment #17)
 Manuel has a good patch for this.  I don't know what's holding it up.
 

Some issues were raised, in particular, my patch doesn't warn about functions
in anonymous namespaces:
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01103.html
I don't think that is solvable at the present moment. I am going to submit just
the C bits, since that seems ok. We could open a PR for C++, since anyway the
code is not shared at all.


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-03-03 Thread patchapp at dberlin dot org


--- Comment #16 from patchapp at dberlin dot org  2007-03-03 11:50 ---
Subject: Bug number PR c/4076

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg00171.html


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-02-16 Thread manu at gcc dot gnu dot org


--- Comment #12 from manu at gcc dot gnu dot org  2007-02-16 09:53 ---
I get warning for gcc/testsuite/objc.dg/headers.m

/home/manuel/src/trunk/gcc/testsuite/../../libobjc/objc/objc-list.h:144:
warning: 'list_free' defined but not used

What should I do about this?

1) there is no warning if I add the keyword inline to objc-list.h
(list_free).
2) add -Wno-unused-function to the testcase.
3) ??


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-02-16 Thread mrs at apple dot com


--- Comment #13 from mrs at apple dot com  2007-02-16 17:59 ---
Adding inline seems obvious to me, all the other functions are marked inline.


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-02-16 Thread pinskia at gcc dot gnu dot org


--- Comment #14 from pinskia at gcc dot gnu dot org  2007-02-16 21:33 
---
(In reply to comment #12) 
 1) there is no warning if I add the keyword inline to objc-list.h
 (list_free).

I preapprove the patch which adds the keyword inline to that function.

Thanks,
Andrew Pinski


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-02-16 Thread manu at gcc dot gnu dot org


--- Comment #15 from manu at gcc dot gnu dot org  2007-02-16 23:35 ---
(In reply to comment #14)
 (In reply to comment #12) 
  1) there is no warning if I add the keyword inline to objc-list.h
  (list_free).
 
 I preapprove the patch which adds the keyword inline to that function.
 
 Thanks,
 Andrew Pinski
 

Oh, thanks! I will prepare the patch, commit it and send it to gcc-patches just
for reference.


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-01-29 Thread manu at gcc dot gnu dot org


--- Comment #10 from manu at gcc dot gnu dot org  2007-01-29 18:08 ---
(In reply to comment #9)
 I will submit two patches. The first one will remove the function. Then, I 
 have
 to regtest the second one: perhaps we find another unused function!

Another one:

genautomata.c: static int longest_path_length (state_t state)

Should also be removed completely?


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-01-29 Thread stevenb dot gcc at gmail dot com


--- Comment #11 from stevenb dot gcc at gmail dot com  2007-01-29 18:22 
---
Subject: Re:  -Wunused doesn't warn about static function only called by
itself.

If it is unused, don't hesitate to remove it.  :-)


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-01-28 Thread manu at gcc dot gnu dot org


--- Comment #9 from manu at gcc dot gnu dot org  2007-01-28 17:23 ---
I will submit two patches. The first one will remove the function. Then, I have
to regtest the second one: perhaps we find another unused function!

Steven, if you really think that the case:

static void foo(void)
{
 bar ();
}

static void bar(void)
{
 foo ();
}

is worth the hassle of dealing with the call graph (which may not be available
unless using a particular -O* switch), please open a new PR about it (and add
me to the CC list).


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-01-27 Thread manu at gcc dot gnu dot org


--- Comment #4 from manu at gcc dot gnu dot org  2007-01-27 15:45 ---
The funny thing is that if we fix this, bootstrap will break (with a warning
treated as an error) on tree-optimize.c (update_inlined_to_pointers) since it
seems that that function is only used by itself.

Is it dead code that we can remove or there is something weird going on?


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-01-27 Thread manu at gcc dot gnu dot org


--- Comment #5 from manu at gcc dot gnu dot org  2007-01-27 15:46 ---
Anyway, here is my current patch, perhaps someone can find some use for it:

Index: gcc/testsuite/gcc.dg/Wunused-function.c
===
--- gcc/testsuite/gcc.dg/Wunused-function.c (revision 0)
+++ gcc/testsuite/gcc.dg/Wunused-function.c (revision 0)
@@ -0,0 +1,6 @@
+/* PR c/4076  -Wunused doesn't warn about static function only called by
itself.  */
+/* { dg-do compile } */
+/* { dg-options -Wunused-function } */
+
+static void foo (void) {} /* { dg-warning 'foo' defined but not used } */
+static void bar (void) { bar (); } /* { dg-warning 'bar' defined but not
used } */
Index: gcc/c-typeck.c
===
--- gcc/c-typeck.c  (revision 121039)
+++ gcc/c-typeck.c  (working copy)
@@ -2077,9 +2077,13 @@ build_external_ref (tree id, int fun, lo
   if (TREE_DEPRECATED (ref))
 warn_deprecated_use (ref);

-  if (!skip_evaluation)
-assemble_external (ref);
-  TREE_USED (ref) = 1;
+  /* Recursive calls does not count as usage.  */
+  if (ref != current_function_decl)
+{
+  if (!skip_evaluation)
+   assemble_external (ref);
+  TREE_USED (ref) = 1;
+}

   if (TREE_CODE (ref) == FUNCTION_DECL  !in_alignof)
 {
Index: gcc/calls.c
===
--- gcc/calls.c (revision 121039)
+++ gcc/calls.c (working copy)
@@ -1449,7 +1449,7 @@ rtx_for_function_call (tree fndecl, tree
 {
   /* If this is the first use of the function, see if we need to
 make an external definition for it.  */
-  if (! TREE_USED (fndecl))
+  if (!TREE_USED (fndecl)  fndecl != current_function_decl)
{
  assemble_external (fndecl);
  TREE_USED (fndecl) = 1;


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-01-27 Thread hubicka at gcc dot gnu dot org


--- Comment #6 from hubicka at gcc dot gnu dot org  2007-01-27 15:57 ---
update_inlined_to_pointers is obviously no longer needed and can be safely
removed now. Thanks for noticing it ;)

Honza


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-01-27 Thread manu at gcc dot gnu dot org


--- Comment #7 from manu at gcc dot gnu dot org  2007-01-27 16:04 ---
So then, should I prepare two separated patches or just one for everything ?


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2007-01-27 Thread stevenb dot gcc at gmail dot com


--- Comment #8 from stevenb dot gcc at gmail dot com  2007-01-27 19:58 
---
Subject: Re:  -Wunused doesn't warn about static function only called by
itself.

Just one for everything should suffice.

Or, if you prefer, you can remove that one function with a separate
patch first, which, I believe, you can commit as obviously correct
(given that the author of that function and authority of its usage
already ack'ed that the function is dead code).

Thanks for working on this.


-- 


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2006-02-09 Thread steven at gcc dot gnu dot org


-- 

steven at gcc dot gnu dot org changed:

   What|Removed |Added

 CC|stevenb at suse dot de  |
 AssignedTo|unassigned at gcc dot gnu   |steven at gcc dot gnu dot
   |dot org |org
 Status|NEW |ASSIGNED
   Last reconfirmed|2005-12-10 05:42:48 |2006-02-09 23:10:39
   date||


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



[Bug c/4076] -Wunused doesn't warn about static function only called by itself.

2005-02-09 Thread pinskia at gcc dot gnu dot org


-- 
   What|Removed |Added

 CC||pinskia at gcc dot gnu dot
   ||org
   Last reconfirmed|2004-08-04 06:15:46 |2005-02-10 05:36:25
   date||


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