This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug driver/58512] New: [Feature request] -Wformat extensions to accomodate custom rules
- From: "daniel.santos at pobox dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 23 Sep 2013 20:09:48 +0000
- Subject: [Bug driver/58512] New: [Feature request] -Wformat extensions to accomodate custom rules
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58512
Bug ID: 58512
Summary: [Feature request] -Wformat extensions to accomodate
custom rules
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: driver
Assignee: unassigned at gcc dot gnu.org
Reporter: daniel.santos at pobox dot com
I am working on a Linux kernel patch set to add a feature comprable to glibc's
%m format specifier. However, glibc's extensions uses errno which, of course,
doesn't exist in the kernel. Therefore, if I wanted to use %m, I would trigger
-Wformat warnings due to the unexpected argument(s).
The Linux kernel currently has many extensions to printf
(http://lxr.free-electrons.com/source/lib/vsprintf.c#L1466) which operate by
adding a suffix to an existing format specifier, preventing any breakage due to
-Wformat. But it is also limiting because new format specifiers must be
implemented via suffixes, which consequently increase data size (be it ever so
slightly). It would be helpful to have a mechanism to tell gcc that you are
extending the format rule checks in x fashion. For example:
* Define new archetype named "linux_printf" extending "printf"
* Remove %m rule.
* Add %m rule, defined as <takes signed int argument>.
Then in the __attribute__ printf declaration, one would simply use the
linux_printf for the archetype name.