public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "m-matti-a.lehtonen at iki dot fi" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/52105] New: Improved dead code identifying -Wunused-function?
Date: Fri, 03 Feb 2012 12:27:00 -0000	[thread overview]
Message-ID: <bug-52105-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             Bug #: 52105
           Summary: Improved dead code identifying -Wunused-function?
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: m-matti-a.lehtonen@iki.fi


In the code below, GCC gives warnings
foobar.h:*:20: warning: ‘bar2a’ declared ‘static’ but never defined
[-Wunused-function]
foobar.c:*:20: warning: ‘bar2b’ declared ‘static’ but never defined
[-Wunused-function]
foobar.c:*:13: warning: ‘foo’ defined but not used [-Wunused-function]

How ever, dead code, 'bar3b' or 'bar4' functions does not generate a warning
like 'foo' does (gcc man page says: "Warn whenever a static function is
declared but not defined or a non-inline static function is unused").  I
wonder, if -Wunused-function could improved to generate warnings of inlined
static functions that are not in header file or included to compiled file,
while using C99 standard for compilation. 

//foobar.h
inline void bar( void );
inline void bar( void ) {}

static inline void bar1( void );
static inline void bar1( void ) {}

static inline void bar2a( void );

static inline void bar3a( void ) {}

static inline void bar5( void ) {}

//foobar.c
extern void bar( void );
extern void bar1( void );

static inline void bar2b( void );

static inline void bar3b( void ) {}

static inline void bar4( void );
static inline void bar4( void ) {}

extern void bar5( void );

static void foo( void ) {}

CMD line used:
cc -c -o foobar.o -Wall -Wmissing-prototypes -Wpointer-arith -Wreturn-type
-Wswitch -Wcast-qual -Wwrite-strings -O0 -g -Wunused-result -Wunreachable-code
-Wswitch-default -Wextra -Wshadow -Wstack-protector -std=gnu99
-fstack-protector -fstack-check  ... foobar.c


             reply	other threads:[~2012-02-03 12:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03 12:27 m-matti-a.lehtonen at iki dot fi [this message]
2012-02-03 13:31 ` [Bug c/52105] " rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-52105-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).