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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126144
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-06-30 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ 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.
+
2007-06-30 Richard Sandiford <richard@codesourcery.com>
Revert:
if (TREE_DEPRECATED (ref))
warn_deprecated_use (ref);
- if (!skip_evaluation)
- assemble_external (ref);
- TREE_USED (ref) = 1;
+ /* Recursive call 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)
{
{
/* 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;
+2007-06-30 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR c/4076
+ * gcc.dg/Wunused-function.c: New.
+
2007-06-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
* gfortran.fortran-torture/compile/inline_1.f90: Fix test.
--- /dev/null
+/* 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" } */