Silently checking whether diagnostics would occur

Kaveh R. Ghazi
Fri Sep 15 11:12:00 GMT 2000

 > From: "Joseph S. Myers" <>
 > 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 R. Ghazi			Engagement Manager / Project Services		Qwest Internet Solutions

More information about the Gcc mailing list