[PING^2] [C/C++] PR c/4076 -Wunused doesn't warn about static function only called by itself

Gabriel Dos Reis gdr@cs.tamu.edu
Fri Mar 16 15:29:00 GMT 2007


"Manuel López-Ibáñez" <lopezibanez@gmail.com> writes:

| On 15/03/07, Nathan Sidwell <nathan@codesourcery.com> wrote:
| > Manuel López-Ibáñez wrote:
| >
| > > Index: gcc/cp/semantics.c
| > > ===================================================================
| > > --- gcc/cp/semantics.c        (revision 122472)
| > > +++ gcc/cp/semantics.c        (working copy)
| > > @@ -2852,7 +2852,8 @@ finish_id_expression (tree id_expression
| > >         if (TREE_CODE (first_fn) == TEMPLATE_DECL)
| > >           first_fn = DECL_TEMPLATE_RESULT (first_fn);
| > >
| > > -       if (!really_overloaded_fn (decl))
| > > +       /* Recursive call does not count as usage.  */
| > > +       if (!really_overloaded_fn (decl) && decl != current_function_decl)
| > >           mark_used (first_fn);
| > >
| > >         if (!template_arg_p
| >
| > what about the other mark_used earlier on in that function:
| >
| >        if (scope)
| >         {
| >           decl = (adjust_result_of_qualified_name_lookup
| >                   (decl, scope, current_class_type));
| >
| >           if (TREE_CODE (decl) == FUNCTION_DECL)
| >             mark_used (decl);
| >
| > why not similarly protect that?  the other c++ bits are ok.
| >
| > nathan
| 
| I could but I was not able to construct a case where it was necessary.
| How can a static function make a scoped recursive call?
                                   ^^^^^^^^^^^^^^^^^^^^

I'm unclear about what you mean by that.

-- Gaby



More information about the Gcc-patches mailing list