This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Silently checking whether diagnostics would occur

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:		phone: +1 978-486-9304
Non-work:	fax:   +1 978-692-4482

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]