This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: -Wunused-macros
Kaveh R. Ghazi wrote:-
> I think the new feature is useful in general, however I'm worried
> people on one platform where a macro isn't used may erroneously delete
> the definition and accidentally hose other platforms. This is very
> easy in gcc sources have so many conditional things depending on the
> target.
I'd expect someone removing something to be more careful; a simple
compiler warning is not an excuse. Arguably, the macro should also
be fixed.
> This seems more likely to me with the other feature you hinted at, for
> supposendly "unused" headers.
Yes. Hmmm; I don't think there's a perfect answer here. What does the
lint software do that has a similar feature?
> Is there some way to address this potential problem?
It's possible to flag the identifier when it's looked up the second
time as being used. But that flags things that are not uses as being
uses, e.g.
#define f()
f bar
would flag f as being used, which I don't do at present since it's
not expanded. Slightly pathological, I know, but consider
#define foo
#undef foo
Here I report foo as unused, but if I use a hash table lookup to mark
foo as used, then the undef code has no chance of knowing whether it
was the cause of the usage, and would not report the warning. There
are other examples, too.
> Warning noise is a problem we should avoid. If we can't silence them
> then I would rather not put these in -Wall.
It's easy to shut up, if you're willing to add a meaningless
#if defined A || defined B || ...
#endif
Some are just scoping issues which could be fixed; others would probably
have to be worked around like this (but I've not looked in detail).
Neil.