public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Unused macros warning?
@ 2002-07-22  5:22 Neil Booth
  2002-07-22 13:03 ` Paul Koning
  2002-07-23  5:15 ` Zack Weinberg
  0 siblings, 2 replies; 4+ messages in thread
From: Neil Booth @ 2002-07-22  5:22 UTC (permalink / raw)
  To: gcc; +Cc: Zack Weinberg

I made a local modification to cpplib so that, if -Wunused, it reports
all macros defined in the main file that are unused, or unused before
being #undef-ed.

Might this be a useful addition to mainline?  It shouldn't be in -Wall,
as it involves a slightly expensive hashtable walk at the end of
preprocessing which most users wouldn't want to pay for, but could
be enabled with the front ends' -Wunused, say.

Long-term, it would be nice if cpplib could tell you if any header you
include is not used for any purpose.  The kernel guys have wanted this
feature for a long time.  I think it's not too hard, once the front end
uses logical lines internally; it then just becomes a matter of
reporting a line as "used" when something from it (like a macro, struct,
typedef etc.) is used, and letting cpplib use the line maps to convert
that to file usage, and doing a quick pass over the linemap structures
at the end of preprocessing.

Neil.

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

* Re: Unused macros warning?
  2002-07-22  5:22 Unused macros warning? Neil Booth
@ 2002-07-22 13:03 ` Paul Koning
  2002-07-23  5:15 ` Zack Weinberg
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Koning @ 2002-07-22 13:03 UTC (permalink / raw)
  To: neil; +Cc: gcc

>>>>> "Neil" == Neil Booth <neil@daikokuya.co.uk> writes:

 Neil> I made a local modification to cpplib so that, if -Wunused, it
 Neil> reports all macros defined in the main file that are unused, or
 Neil> unused before being #undef-ed.

 Neil> Might this be a useful addition to mainline?  It shouldn't be
 Neil> in -Wall, as it involves a slightly expensive hashtable walk at
 Neil> the end of preprocessing which most users wouldn't want to pay
 Neil> for, but could be enabled with the front ends' -Wunused, say.

I assume you would also add a -Wunused-macros so you can separately
enable or disable this.  The latter is important if I want the
existing unused warnings but not this new one.

	 paul

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

* Re: Unused macros warning?
  2002-07-22  5:22 Unused macros warning? Neil Booth
  2002-07-22 13:03 ` Paul Koning
@ 2002-07-23  5:15 ` Zack Weinberg
  2002-07-23 22:31   ` David O'Brien
  1 sibling, 1 reply; 4+ messages in thread
From: Zack Weinberg @ 2002-07-23  5:15 UTC (permalink / raw)
  To: Neil Booth; +Cc: gcc

On Mon, Jul 22, 2002 at 07:33:52AM +0100, Neil Booth wrote:
> I made a local modification to cpplib so that, if -Wunused, it reports
> all macros defined in the main file that are unused, or unused before
> being #undef-ed.
> 
> Might this be a useful addition to mainline?  It shouldn't be in -Wall,
> as it involves a slightly expensive hashtable walk at the end of
> preprocessing which most users wouldn't want to pay for, but could
> be enabled with the front ends' -Wunused, say.

Yes, I think this would be useful, as long as it doesn't ding you for
macros in headers.

> Long-term, it would be nice if cpplib could tell you if any header you
> include is not used for any purpose.  The kernel guys have wanted this
> feature for a long time.

Oooh, I want this.

> I think it's not too hard, once the front end uses logical lines
> internally; it then just becomes a matter of reporting a line as
> "used" when something from it (like a macro, struct, typedef etc.)
> is used, and letting cpplib use the line maps to convert that to
> file usage, and doing a quick pass over the linemap structures at
> the end of preprocessing.

Sounds plausible.

zw

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

* Re: Unused macros warning?
  2002-07-23  5:15 ` Zack Weinberg
@ 2002-07-23 22:31   ` David O'Brien
  0 siblings, 0 replies; 4+ messages in thread
From: David O'Brien @ 2002-07-23 22:31 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: Neil Booth, gcc

On Mon, Jul 22, 2002 at 10:55:29PM -0700, Zack Weinberg wrote:
> > Long-term, it would be nice if cpplib could tell you if any header you
> > include is not used for any purpose.  The kernel guys have wanted this
> > feature for a long time.
> 
> Oooh, I want this.

http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/tools/kerninclude/kerninclude.sh

is the script we use to do this with FreeBSD.

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

end of thread, other threads:[~2002-07-23 22:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-22  5:22 Unused macros warning? Neil Booth
2002-07-22 13:03 ` Paul Koning
2002-07-23  5:15 ` Zack Weinberg
2002-07-23 22:31   ` David O'Brien

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