diff options
author | Joseph Myers <joseph@codesourcery.com> | 2021-10-12 23:40:17 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2021-10-12 23:40:17 +0000 |
commit | bd6f2c63168e89bede631daf8b673eab16acc747 (patch) | |
tree | 9d35dfdad7b6b4a956f8741d5eab9acfd8090538 /libiberty | |
parent | 76ba473b99c30ddec6171840a76292d6d4b67e7c (diff) | |
download | gcc-bd6f2c63168e89bede631daf8b673eab16acc747.zip gcc-bd6f2c63168e89bede631daf8b673eab16acc747.tar.gz gcc-bd6f2c63168e89bede631daf8b673eab16acc747.tar.bz2 |
c-family: Support format checking C2X %b, %B formats
C2X adds a %b printf format to print integers in binary (analogous to
%x, including %#b printing a leading 0b on nonzero integers), with
recommended practice for a corresponding %B (where %#B uses 0B instead
of 0b) where that doesn't conflict with existing implementation
extensions. See N2630 for details (accepted for C2X, not yet in the
latest working draft). There is also a scanf %b format.
Add corresponding format checking support (%b accepted by -std=c2x
-Wformat -pedantic, %B considered an extension to be diagnosed with
-Wformat -pedantic). glibc support for the printf formats has been
proposed at
<https://sourceware.org/pipermail/libc-alpha/2021-October/131764.html>
(scanf support to be done in a separate patch).
Note that this does not add any support for these formats to the code
for bounding the amount of output produces by a printf function,
although that would also be useful.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/c-family/
* c-format.c (print_char_table): Add %b and %B formats.
(scan_char_table): Add %b format.
* c-format.h (T2X_UI, T2X_UL, T2X_ULL, T2X_US, T2X_UC, T2X_ST)
(T2X_UPD, T2X_UIM): New macros.
gcc/testsuite/
* gcc.dg/format/c11-printf-1.c, gcc.dg/format/c11-scanf-1.c,
gcc.dg/format/c2x-printf-1.c, gcc.dg/format/c2x-scanf-1.c,
gcc.dg/format/ext-9.c, gcc.dg/format/ext-10.c: New tests.
Diffstat (limited to 'libiberty')
0 files changed, 0 insertions, 0 deletions