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: unassig...@gcc.gnu.org
        ReportedBy: m-matti-a.lehto...@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 via email to