https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47781

--- Comment #14 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #13)
> I have been reconsidering the plugin approach given some new things
> I learned about the details of the firefox code (namely that it doesn't
> faithfully follow printf semantics, sigh).
> 
> One additional note for this bug is that it would be nice if any
> such addition by a plugin worked properly with -Wmissing-format-attribute.

Note that plugins can define attributes. Perhaps one way to go about this would
be to create a plugin that parsed some kind of GCC_printf_format_info attribute
that matches GCC internal printf checking. Then move GCC own format checking to
use this attribute and enable the plugin by default when building GCC.

This will give you as much flexibility as GCC format checking supports, and the
plugin will be developed, build, tested and distributed alongside GCC. Users
outside GCC just need to use the plugin and add the attributes to their own
printf-style functions. Moreover, since the plugin is developed alongside GCC,
it would be logical to add whatever hooks the plugin needs.

Moreover, nothing stops users from creating some kind of intermediate language
that simplifies custom printf attribute syntax. Probably some C preprocessor
magic could be enough.

The challenge is the define the syntax of the attribute, but I think this
challenge is unavoidable for whoever wants to implement this. You may present a
simplified syntax to the user, but you still need to handle correctly all the
complexity and corner cases in c-format.c.

Reply via email to