public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Michael Meissner <meissner@cygnus.com>
To: "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu>
Cc: meissner@cygnus.com, gcc@gcc.gnu.org, gdr@codesourcery.com
Subject: Re: Silently checking whether diagnostics would occur
Date: Wed, 13 Sep 2000 20:37:00 -0000	[thread overview]
Message-ID: <20000913233709.38715@cse.cygnus.com> (raw)
In-Reply-To: <200009132133.RAA05494@caip.rutgers.edu>

On Wed, Sep 13, 2000 at 05:33:36PM -0400, Kaveh R. Ghazi wrote:
> If you mean rewriting check_format_info, that requires a lot of
> obtrusive surgery on the code.  As I mentioned above, that function is
> not structured to return a status either as a return-value, or via one
> of its parameters were I to add one.  There are about 50 places in
> that function which warn about format specifier problems.  I would
> have to add bits at each location to mark that a warning occured and
> return that bit at all of the 15 spots from which the function can
> return.  Anyone writing new format warnings within it would have to
> remember to do the same.  Its really hairy.  My alternative is about
> five lines of code.
>
> What is the specific problem you wish to avoid that global vars cause?
> Is there some other way to design this to meet your goals?  What if
> the setting were a static variable in diagnostic.c with functions
> exported to set/unset it?

I just don't like global variables changing the behavior of functions,
particularly error reporting functions.  It is gross.  The problem is once you
have this global, somebody else is going to use it, and sooner or later these
two passes (or a backend and a MI pass) will use the variable in such a
non-obvious way.

Rather than returning an error value, you could have the parameter be an int
pointer, and if the pointer is NULL, otherwise set the pointer to non-zero and
return.  Another way to write the function is to pass a function that writes
the error messages, and for the case you don't want the error messages, have it
record in a static about being called and return, and change the other callers
to pass error or what have you for the function.

-- 
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

  reply	other threads:[~2000-09-13 20:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-13 14:33 Kaveh R. Ghazi
2000-09-13 20:37 ` Michael Meissner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-09-15 11:25 Kaveh R. Ghazi
2000-09-15 11:12 Kaveh R. Ghazi
2000-09-14  8:31 Kaveh R. Ghazi
2000-09-14  8:42 ` Michael Meissner
2000-09-14 10:47 ` Joseph S. Myers
2000-09-14 12:37 ` Joern Rennecke
2000-09-14  7:43 Kaveh R. Ghazi
2000-09-13 17:38 Mike Stump
2000-09-13  8:50 Kaveh R. Ghazi
2000-09-13 13:51 ` Michael Meissner
2000-09-13 16:37 ` Joern Rennecke

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=20000913233709.38715@cse.cygnus.com \
    --to=meissner@cygnus.com \
    --cc=gcc@gcc.gnu.org \
    --cc=gdr@codesourcery.com \
    --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).