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: jsm28 at cam dot ac dot uk
- Subject: Re: Silently checking whether diagnostics would occur
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Fri, 15 Sep 2000 14:12:19 -0400 (EDT)
- Cc: amylaar at cygnus dot co dot uk, gcc at gcc dot gnu dot org, gdr at codesourcery dot com, meissner at cygnus dot com
> From: "Joseph S. Myers" <jsm28@cam.ac.uk>
>
> 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.
I agree, would you like to fix it? :-)
I looked at this a year ago, but lost interest. If you want to take a
stab by all means please do.
The first problem is that in c-common.c:decl_attributes, the A_FORMAT
case specifically errors when it receives something that is not a
FUNCTION_DECL. So you need to also handle POINTER_TYPEs (for function
pointers) or AGGREGATE_TYPEs (for arrays or structs containing
function pointers), as well descending subexpressions of these, until
you get to the eventual FUNCTION_DECL if you want to fix this.
That's just to get the attribute to be accepted. You also have to
muck with c-typeck.c:build_function_call to actually do the
appropriate checks.
>
> 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 haven't seen his patch, so I can't say.
--Kaveh
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Qwest Internet Solutions