public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/52105] New: Improved dead code identifying -Wunused-function?
@ 2012-02-03 12:27 m-matti-a.lehtonen at iki dot fi
  2012-02-03 13:31 ` [Bug c/52105] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: m-matti-a.lehtonen at iki dot fi @ 2012-02-03 12:27 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/52105] Improved dead code identifying -Wunused-function?
  2012-02-03 12:27 [Bug c/52105] New: Improved dead code identifying -Wunused-function? m-matti-a.lehtonen at iki dot fi
@ 2012-02-03 13:31 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-02-03 13:31 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WONTFIX

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-03 13:31:10 UTC ---
There is no such thing as "a header" - the C compiler sees a complete
preprocessed translation unit.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-03 13:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-03 12:27 [Bug c/52105] New: Improved dead code identifying -Wunused-function? m-matti-a.lehtonen at iki dot fi
2012-02-03 13:31 ` [Bug c/52105] " rguenth at gcc dot gnu.org

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).