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

Manuel López-Ibáñez lopezibanez@gmail.com
Fri Mar 16 15:42:00 GMT 2007


On 16 Mar 2007 06:04:41 -0500, Gabriel Dos Reis <gdr@cs.tamu.edu> wrote:
> "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.
>

I mean, how can a recursive call of a static function can enter in the
condition guarded by 'if (scope)' ? Nathan provided an example. If you
have more examples, I would like to add them to the testcase.

Cheers,

Manuel.



More information about the Gcc-patches mailing list