This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


I ping my original patch:
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg00171.html
because it worked fine for its intended purpose. The only case for
which it seems it doesn't work is for functions inside of anonymous
namespaces. However, those are not considered static functions anyway
and -Wunused-function only warns for static functions. So no matter
what my patch does, they are not going to be used. Also, moving the
condition into mark_used causes a weird ICE.

An alternative would be to fix the issue in the C front-end and open a
new PR exclusively for the C++ front-end.

Cheers,

Manuel.

On 24/03/07, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
On 19/03/07, Nathan Sidwell <nathan@codesourcery.com> wrote:
> Manuel López-Ibáñez wrote:
>
> > I can copy the condition. Much better, I can put it inside mark_used
> > so we don't have to duplicate it everywhere.
>
> that seems a much better approach :)
>

Bad news. It produces ICE in:
libstdc++-v3/src/pool_allocator.cc:112: internal compiler error: in
build_call_a, at cp/call.c:325

 if (TREE_CODE (function) == ADDR_EXPR
      && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL)
    {
      decl = TREE_OPERAND (function, 0);
      if (!TREE_USED (decl))
        {
          /* We invoke build_call directly for several library
             functions.  These may have been declared normally if
             we're building libgcc, so we can't just check
             DECL_ARTIFICIAL.  */
          gcc_assert (DECL_ARTIFICIAL (decl)
                      || !strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)),
                                   "__", 2));
          mark_used (decl);
        }
    }

DECL_ARTIFICIAL is false and IDENTIFIER_POINTER (DECL_NAME (decl)) is
"_M_allocate_chunk"

Any ideas?


> > It seems that check_global_declarations, which is the one that emits > > the Wunused-function warnings, is not called for functions in an > > anonymous namespace. I tried finding where the decision is made > > without any success. Any ideas? > > sorry, nothing comes to mind. It is an orthogonal issue though, IMHO. >

So what is the point in making my patch to worry about functions in
anonymous namespaces if anyway they are not equivalent to static with
respect to TREE_USED ? That is, no matter what my patch does, the
warning is not going to be emitted.

Cheers,
Manuel.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]