From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 64BBA385DC2F; Wed, 14 Feb 2024 13:37:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64BBA385DC2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707917851; bh=X1elCDFkPaKW7KBOjKBmztatQhMLr8VGay7GMW5Wzjc=; h=From:To:Subject:Date:From; b=OarTdllXMUwYp4Ew51E9EOJTIVwVT7JCkvTVmXbxLM6n6Bjw31cD0uDLvw+J4xwW7 IyTo6p8Xwn4ssCK8f25ECnveCs3t598bzYQ7yNVpXNzlFOJ2qmV6METsBnmyCTB7mW daU9W5UItlgxnnO1BMh14lVS6w8f41zF09h/WqbU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8977] testsuite: Add %[zt][diox] tests to gcc.dg/format/ X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: e8971ef99505161d09c9bf0174b38fa15fc6e59f X-Git-Newrev: d04eeb472a86c1b7ed129900e9166b4d4e6aea88 Message-Id: <20240214133731.64BBA385DC2F@sourceware.org> Date: Wed, 14 Feb 2024 13:37:31 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d04eeb472a86c1b7ed129900e9166b4d4e6aea88 commit r14-8977-gd04eeb472a86c1b7ed129900e9166b4d4e6aea88 Author: Jakub Jelinek Date: Wed Feb 14 14:36:44 2024 +0100 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 * 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. Diff: --- gcc/testsuite/gcc.dg/format/gcc_diag-1.c | 13 ++++++++++++- 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 4a64d5460c6f..5681332fbc2e 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 7e079b776920..ab26dcf0703a 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);