public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8977] testsuite: Add %[zt][diox] tests to gcc.dg/format/
@ 2024-02-14 13:37 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2024-02-14 13:37 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d04eeb472a86c1b7ed129900e9166b4d4e6aea88

commit r14-8977-gd04eeb472a86c1b7ed129900e9166b4d4e6aea88
Author: Jakub Jelinek <jakub@redhat.com>
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  <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.

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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-14 13:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-14 13:37 [gcc r14-8977] testsuite: Add %[zt][diox] tests to gcc.dg/format/ Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).