diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-02-14 14:36:44 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2024-02-14 14:36:44 +0100 |
commit | d04eeb472a86c1b7ed129900e9166b4d4e6aea88 (patch) | |
tree | b0c408c45aee867c1649730fac9d411f67c1c44c /gcc | |
parent | e8971ef99505161d09c9bf0174b38fa15fc6e59f (diff) | |
download | gcc-d04eeb472a86c1b7ed129900e9166b4d4e6aea88.zip gcc-d04eeb472a86c1b7ed129900e9166b4d4e6aea88.tar.gz gcc-d04eeb472a86c1b7ed129900e9166b4d4e6aea88.tar.bz2 |
testsuite: Add %[zt][diox] tests to gcc.dg/format/
On Mon, Feb 12, 2024 at 04:10:33PM +0000, Joseph Myers wrote:
> Please also add some tests of format checking for these modifiers in
> gcc.dg/format/gcc_*.c.
The following patch does that.
Haven't added tests for bad type (but I think we don't have them in
c99-printf* either) for these because it is hard to figure out what
type from {,unsigned }{int,long,long long} size_t/ptrdiff_t certainly
is not, guess one could do that with preprocessor conditionals, e.g.
comparing __PTRDIFF_MAX__ with __INT_MAX__, __LONG_MAX__ and
__LONG_LONG_MAX__ and pick up the one which is different; but we'd need
to find out corresponding effective targets for the expected diagnostics.
2024-02-14 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/format/gcc_diag-1.c (foo): Add tests for z and t modifiers.
* gcc.dg/format/gcc_gfc-1.c (foo): Add tests for ll, z and t modifiers.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/format/gcc_diag-1.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/format/gcc_gfc-1.c | 8 |
2 files changed, 19 insertions, 2 deletions
diff --git a/gcc/testsuite/gcc.dg/format/gcc_diag-1.c b/gcc/testsuite/gcc.dg/format/gcc_diag-1.c index 4a64d54..5681332 100644 --- a/gcc/testsuite/gcc.dg/format/gcc_diag-1.c +++ b/gcc/testsuite/gcc.dg/format/gcc_diag-1.c @@ -33,7 +33,8 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p, ullong ull, unsigned int *un, const int *cn, signed char *ss, unsigned char *us, const signed char *css, unsigned int u1, unsigned int u2, location_t *loc, tree t1, union tree_node *t2, - tree *t3, tree t4[], int *v, unsigned v_len) + tree *t3, tree t4[], int *v, unsigned v_len, size_t sz, ptrdiff_t pd, + ssize_t ssz, unsigned_ptrdiff_t upd) { /* Acceptable C90 specifiers, flags and modifiers. */ diag ("%%"); @@ -66,6 +67,16 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p, cdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull); cxxdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull); dump ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull); + diag ("%zd%zi%zo%zu%zx", ssz, ssz, sz, sz, sz); + tdiag ("%zd%zi%zo%zu%zx", ssz, ssz, sz, sz, sz); + cdiag ("%zd%zi%zo%zu%zx", ssz, ssz, sz, sz, sz); + cxxdiag ("%zd%zi%zo%zu%zx", ssz, ssz, sz, sz, sz); + dump ("%zd%zi%zo%zu%zx", ssz, ssz, sz, sz, sz); + diag ("%td%ti%to%tu%tx", pd, pd, upd, upd, upd); + tdiag ("%td%ti%to%tu%tx", pd, pd, upd, upd, upd); + cdiag ("%td%ti%to%tu%tx", pd, pd, upd, upd, upd); + cxxdiag ("%td%ti%to%tu%tx", pd, pd, upd, upd, upd); + dump ("%td%ti%to%tu%tx", pd, pd, upd, upd, upd); diag ("%.*s", i, s); tdiag ("%.*s", i, s); cdiag ("%.*s", i, s); diff --git a/gcc/testsuite/gcc.dg/format/gcc_gfc-1.c b/gcc/testsuite/gcc.dg/format/gcc_gfc-1.c index 7e079b7..ab26dcf 100644 --- a/gcc/testsuite/gcc.dg/format/gcc_gfc-1.c +++ b/gcc/testsuite/gcc.dg/format/gcc_gfc-1.c @@ -12,13 +12,19 @@ extern int gfc_warn (const char *, ...) __attribute__ ((__format__ (__gcc_gfc__, void foo (unsigned int u, int i, char *s, unsigned long int ul, long int l, - llong ll, locus *loc) + llong ll, unsigned long long int ull, locus *loc, size_t sz, + ptrdiff_t pd, ssize_t ssz, unsigned_ptrdiff_t upd) { /* Acceptable C90 specifiers, flags and modifiers. */ gfc_warn ("%%"); gfc_warn ("%u%d%i%c%s%%", u, i, i, i, s); gfc_warn ("%lu%ld%li%%", ul, l, l); + /* Acceptable C99 specifiers, flags and modifiers. */ + gfc_warn ("%llu%lld%lli%%", ull, ll, ll); + gfc_warn ("%zu%zd%zi%%", sz, ssz, ssz); + gfc_warn ("%tu%td%ti%%", upd, pd, pd); + /* Extensions provided in gfc_warn. */ gfc_warn ("%C"); gfc_warn ("%L", loc); |