This is the mail archive of the
mailing list for the GCC project.
Re: RFC: should we use -Werror? (& sample patch to do it)
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Subject: Re: RFC: should we use -Werror? (& sample patch to do it)
- From: Zack Weinberg <zack at codesourcery dot com>
- Date: Fri, 7 Sep 2001 19:48:46 -0700
- Cc: gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- References: <200109080139.VAA12035@caip.rutgers.edu>
On Fri, Sep 07, 2001 at 09:39:38PM -0400, Kaveh R. Ghazi wrote:
> > From: Zack Weinberg <email@example.com>
> > (There are cleaner ways to do the same thing, e.g. look at the hack
> > used to avoid -pedantic for the non-C front ends.)
> > zw
> I suppose you're referring to the following from Makefile.in?
> > .-warn = $(STRICT_WARN)
> > GCC_WARN_CFLAGS = $(LOOSE_WARN) $($(@D)-warn)
> I can't figure this out, can you please explain it? How does it work?
$(@D) expands to the directory containing the current target
_as it is referred to in the Makefile_. If the current target is
"toplev.o", $(@D) is ".". If the current target is "java/parse.o",
$(@D) is "java".
When you write a variable reference inside a variable reference, (all
modern versions of) Make expand the inner reference first and mash the
result into the variable name to be looked up by the outer reference.
Therefore, $($(@D)-warn) is equivalent to $(.-warn) for toplev.o,
$(java-warn) for java/parse.o, etc. We set .-warn to $(STRICT_WARN)
and java-warn etc. to empty, we get $(STRICT_WARN) added to
GCC_WARN_CFLAGS for the top level only.
So, how'd you use this for -Werror? Like this:
GCC_WARN_CFLAGS = $(LOOSE_WARN) $($(@D)-warn) $($@-warn)
# These files (and only these) are to have no-warnings enforced.
toplev.o-warn = -Werror
c-common.o-warn = -Werror
cp/parse.o-warn = -Werror
Each Makefile.in and/or Make-lang.in would have the appropriate list
for the files it controls.
I suppose this could also be used to do
combine.o-warn = -Wno-sign-compare
but that would be cheating.
 Make has practically no restrictions on what characters can appear
in a variable name. I think it's just = : $ ( ). You can even have
interior white space.