This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Silently checking whether diagnostics would occur
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Subject: Re: Silently checking whether diagnostics would occur
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Thu, 14 Sep 2000 18:47:25 +0100 (BST)
- cc: meissner at cygnus dot com, amylaar at cygnus dot co dot uk, gcc at gcc dot gnu dot org, gdr at codesourcery dot com
On Thu, 14 Sep 2000, Kaveh R. Ghazi wrote:
> One nit with passing in a function is that attribute printf doesn't
> work on function pointers IIRC, so all the calls to the warning
> function ptr would lose format checks. (Though I suppose that could
> be fixed.) Sigh, that would have been cleaner since I could do
This should probably be considered a bug (which should be fixed) that
format attributes don't attach properly to the function type.
Marc Espie's __attribute__((__nonnull__)) patch allows (I think) for one
function to have multiple printf/scanf attributes (which could make sense
if all but as must one are vprintf/vscanf-like), but I don't know if it
fixes this problem.
> I'll look into passing in an int*, then I guess all calls to warning()
> would instead be:
>
> > if (foo)
> > {*foo = 1; return;}
> > else
> > warning ("blah blah", arg1, arg2);
>
> Although I appreciate now the reasons against using a global var, I
> also see maintenance problems down the road ensuring that one always
> uses the above idiom when adding new format checks.
>
> Any ideas on making it more automatic and less dependent on good
> behavior? Since `warning' is a varargs function, for portability
> reasons I can't make the above snippet a macro.
I'd suggest making this into a format_warning function (taking the int *
and the normal warning() parameters). Remember the calls from tfaff() and
maybe_read_dollar_number() and finish_dollar_format_checking() and adjust
the parameters of these functions to include the int *, and note that
format checking is not presently reentrant because of static variables
used in the $ format checking (I've added reentrancy to my TODO list).
In addition, -pedantic should not affect code generation, so before
calling the format checking the value of `pedantic' should be saved and it
should be set to some known value (I suggest 1).
--
Joseph S. Myers
jsm28@cam.ac.uk