This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/52105] New: Improved dead code identifying -Wunused-function?
- From: "m-matti-a.lehtonen at iki dot fi" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 03 Feb 2012 12:26:47 +0000
- Subject: [Bug c/52105] New: Improved dead code identifying -Wunused-function?
- Auto-submitted: auto-generated
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