public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Zack Weinberg <zack@codesourcery.com>
To: "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu>
Cc: gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org
Subject: Re: RFC: should we use -Werror?  (& sample patch to do it)
Date: Fri, 07 Sep 2001 19:49:00 -0000	[thread overview]
Message-ID: <20010907194846.B386@codesourcery.com> (raw)
In-Reply-To: <200109080139.VAA12035@caip.rutgers.edu>

On Fri, Sep 07, 2001 at 09:39:38PM -0400, Kaveh R. Ghazi wrote:
>  > From: Zack Weinberg <zack@codesourcery.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?

Yes.

>  > .-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.[1]

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.

zw

[1] 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.

  reply	other threads:[~2001-09-07 19:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-07 18:39 Kaveh R. Ghazi
2001-09-07 19:49 ` Zack Weinberg [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-09-07 18:47 Kaveh R. Ghazi
2001-09-06  9:16 dewar
2001-09-05 20:54 Dan Nicolaescu
2001-09-06  8:44 ` Loïc Joly
2001-09-05 20:36 lucier
2001-09-05 12:52 Kaveh R. Ghazi
2001-09-05 15:06 ` Neil Booth
2001-09-05 19:09 ` Zack Weinberg
2001-09-05 12:09 Kaveh R. Ghazi
2001-09-05 12:33 ` Zack Weinberg
2001-09-07 10:10   ` Marc Espie
2001-09-26 16:52 ` Fergus Henderson
2001-09-26 17:05   ` Joseph S. Myers
2001-09-05 10:59 Kaveh R. Ghazi
2001-09-05 11:17 ` Zack Weinberg
2001-09-05 10:44 Kaveh R. Ghazi
2001-09-05 10:39 Kaveh R. Ghazi
2001-09-05 11:50 ` Richard Henderson
2001-09-04 20:32 Kaveh R. Ghazi
2001-09-04 23:32 ` Neil Booth
2001-09-05  0:27 ` Richard Henderson
2001-09-05  6:57 ` Geoff Keating
2001-09-05 10:35 ` Zack Weinberg
2001-09-05 10:40   ` Neil Booth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010907194846.B386@codesourcery.com \
    --to=zack@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=ghazi@caip.rutgers.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).