format.exp: New file.
authorJoseph Myers <jsm28@cam.ac.uk>
Sat, 6 Jan 2001 18:47:19 +0000 (18:47 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sat, 6 Jan 2001 18:47:19 +0000 (18:47 +0000)
* gcc.dg/format/format.exp: New file.
* gcc.dg/c90-printf-1.c: Rename to gcc.dg/format/c90-printf-1.c.
* gcc.dg/c90-printf-2.c: Rename to gcc.dg/format/c90-printf-2.c.
* gcc.dg/c90-printf-3.c: Rename to gcc.dg/format/c90-printf-3.c.
* gcc.dg/c94-printf-1.c: Rename to gcc.dg/format/c94-printf-1.c.
* gcc.dg/c99-printf-1.c: Rename to gcc.dg/format/c99-printf-1.c.
* gcc.dg/c99-printf-2.c: Rename to gcc.dg/format/c99-printf-2.c.
* gcc.dg/c99-printf-3.c: Rename to gcc.dg/format/c99-printf-3.c.
* gcc.dg/c90-scanf-1.c: Rename to gcc.dg/format/c90-scanf-1.c.
* gcc.dg/c90-scanf-2.c: Rename to gcc.dg/format/c90-scanf-2.c.
* gcc.dg/c90-scanf-3.c: Rename to gcc.dg/format/c90-scanf-3.c.
* gcc.dg/c90-scanf-4.c: Rename to gcc.dg/format/c90-scanf-4.c.
* gcc.dg/c94-scanf-1.c: Rename to gcc.dg/format/c94-scanf-1.c.
* gcc.dg/c99-scanf-1.c: Rename to gcc.dg/format/c99-scanf-1.c.
* gcc.dg/c99-scanf-2.c: Rename to gcc.dg/format/c99-scanf-2.c.
* gcc.dg/c99-scanf-3.c: Rename to gcc.dg/format/c99-scanf-3.c.
* gcc.dg/c90-strftime-1.c: Rename to gcc.dg/format/c90-strftime-1.c.
* gcc.dg/c90-strftime-2.c: Rename to gcc.dg/format/c90-strftime-2.c.
* gcc.dg/c99-strftime-1.c: Rename to gcc.dg/format/c99-strftime-1.c.
* gcc.dg/c99-strftime-2.c: Rename to gcc.dg/format/c99-strftime-2.c.
* gcc.dg/format-array-1.c: Rename to gcc.dg/format/array-1.c.
* gcc.dg/format-attr-1.c: Rename to gcc.dg/format/attr-1.c.
* gcc.dg/format-branch-1.c: Rename to gcc.dg/format/branch-1.c.
* gcc.dg/format-diag-1.c: Rename to gcc.dg/format/diag-1.c.
* gcc.dg/format-errmk-1.c: Rename to gcc.dg/format/errmk-1.c.
* gcc.dg/format-ext-1.c: Rename to gcc.dg/format/ext-1.c.
* gcc.dg/format-ext-2.c: Rename to gcc.dg/format/ext-2.c.
* gcc.dg/format-ext-3.c: Rename to gcc.dg/format/ext-3.c.
* gcc.dg/format-ext-4.c: Rename to gcc.dg/format/ext-4.c.
* gcc.dg/format-ext-5.c: Rename to gcc.dg/format/ext-5.c.
* gcc.dg/format-miss-1.c: Rename to gcc.dg/format/miss-1.c.
* gcc.dg/format-miss-2.c: Rename to gcc.dg/format/miss-2.c.
* gcc.dg/format-no-exargs-1.c: Rename to gcc.dg/format/no-exargs-1.c.
* gcc.dg/format-no-y2k-1.c: Rename to gcc.dg/format/no-y2k-1.c.
* gcc.dg/format-nonlit-1.c: Rename to gcc.dg/format/nonlit-1.c.
* gcc.dg/format-nonlit-2.c: Rename to gcc.dg/format/nonlit-2.c.
* gcc.dg/format-nonlit-3.c: Rename to gcc.dg/format/nonlit-3.c.
* gcc.dg/format-sec-1.c: Rename to gcc.dg/format/sec-1.c.
* gcc.dg/format-strfmon-1.c: Rename to gcc.dg/format/strfmon-1.c.
* gcc.dg/format-va-1.c: Rename to gcc.dg/format/va-1.c.
* gcc.dg/format-warnll-1.c: Rename to gcc.dg/format/warnll-1.c.
* gcc.dg/format-xopen-1.c: Rename to gcc.dg/format/xopen-1.c.
* gcc.dg/formatz-1.c: Rename to gcc.dg/format/z-1.c.

From-SVN: r38749

86 files changed:
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/c90-printf-1.c [deleted file]
gcc/testsuite/gcc.dg/c90-printf-2.c [deleted file]
gcc/testsuite/gcc.dg/c90-printf-3.c [deleted file]
gcc/testsuite/gcc.dg/c90-scanf-1.c [deleted file]
gcc/testsuite/gcc.dg/c90-scanf-2.c [deleted file]
gcc/testsuite/gcc.dg/c90-scanf-3.c [deleted file]
gcc/testsuite/gcc.dg/c90-scanf-4.c [deleted file]
gcc/testsuite/gcc.dg/c90-strftime-1.c [deleted file]
gcc/testsuite/gcc.dg/c90-strftime-2.c [deleted file]
gcc/testsuite/gcc.dg/c94-printf-1.c [deleted file]
gcc/testsuite/gcc.dg/c94-scanf-1.c [deleted file]
gcc/testsuite/gcc.dg/c99-printf-1.c [deleted file]
gcc/testsuite/gcc.dg/c99-printf-2.c [deleted file]
gcc/testsuite/gcc.dg/c99-printf-3.c [deleted file]
gcc/testsuite/gcc.dg/c99-scanf-1.c [deleted file]
gcc/testsuite/gcc.dg/c99-scanf-2.c [deleted file]
gcc/testsuite/gcc.dg/c99-scanf-3.c [deleted file]
gcc/testsuite/gcc.dg/c99-strftime-1.c [deleted file]
gcc/testsuite/gcc.dg/c99-strftime-2.c [deleted file]
gcc/testsuite/gcc.dg/format-array-1.c [deleted file]
gcc/testsuite/gcc.dg/format-attr-1.c [deleted file]
gcc/testsuite/gcc.dg/format-branch-1.c [deleted file]
gcc/testsuite/gcc.dg/format-diag-1.c [deleted file]
gcc/testsuite/gcc.dg/format-errmk-1.c [deleted file]
gcc/testsuite/gcc.dg/format-ext-1.c [deleted file]
gcc/testsuite/gcc.dg/format-ext-2.c [deleted file]
gcc/testsuite/gcc.dg/format-ext-3.c [deleted file]
gcc/testsuite/gcc.dg/format-ext-4.c [deleted file]
gcc/testsuite/gcc.dg/format-ext-5.c [deleted file]
gcc/testsuite/gcc.dg/format-miss-1.c [deleted file]
gcc/testsuite/gcc.dg/format-miss-2.c [deleted file]
gcc/testsuite/gcc.dg/format-no-exargs-1.c [deleted file]
gcc/testsuite/gcc.dg/format-no-y2k-1.c [deleted file]
gcc/testsuite/gcc.dg/format-nonlit-1.c [deleted file]
gcc/testsuite/gcc.dg/format-nonlit-2.c [deleted file]
gcc/testsuite/gcc.dg/format-nonlit-3.c [deleted file]
gcc/testsuite/gcc.dg/format-sec-1.c [deleted file]
gcc/testsuite/gcc.dg/format-strfmon-1.c [deleted file]
gcc/testsuite/gcc.dg/format-va-1.c [deleted file]
gcc/testsuite/gcc.dg/format-warnll-1.c [deleted file]
gcc/testsuite/gcc.dg/format-xopen-1.c [deleted file]
gcc/testsuite/gcc.dg/format/array-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/attr-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/branch-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c90-printf-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c90-printf-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c90-printf-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c90-scanf-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c90-scanf-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c90-scanf-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c90-scanf-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c90-strftime-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c90-strftime-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c94-printf-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c94-scanf-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c99-printf-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c99-printf-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c99-printf-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c99-scanf-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c99-scanf-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c99-scanf-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c99-strftime-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/c99-strftime-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/diag-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/errmk-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/ext-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/ext-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/ext-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/ext-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/ext-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/format.exp [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/miss-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/miss-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/no-exargs-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/no-y2k-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/nonlit-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/nonlit-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/nonlit-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/sec-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/strfmon-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/va-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/warnll-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/xopen-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/z-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/formatz-1.c [deleted file]

index e02464653b7ec66205c28a6bef2063eb5a9568ad..2ca4f17588400748e9d2e0214a0789a281e89427 100644 (file)
@@ -1,3 +1,49 @@
+2001-01-06  Joseph S. Myers  <jsm28@cam.ac.uk>
+
+       * gcc.dg/format/format.exp: New file.
+       * gcc.dg/c90-printf-1.c: Rename to gcc.dg/format/c90-printf-1.c.
+       * gcc.dg/c90-printf-2.c: Rename to gcc.dg/format/c90-printf-2.c.
+       * gcc.dg/c90-printf-3.c: Rename to gcc.dg/format/c90-printf-3.c.
+       * gcc.dg/c94-printf-1.c: Rename to gcc.dg/format/c94-printf-1.c.
+       * gcc.dg/c99-printf-1.c: Rename to gcc.dg/format/c99-printf-1.c.
+       * gcc.dg/c99-printf-2.c: Rename to gcc.dg/format/c99-printf-2.c.
+       * gcc.dg/c99-printf-3.c: Rename to gcc.dg/format/c99-printf-3.c.
+       * gcc.dg/c90-scanf-1.c: Rename to gcc.dg/format/c90-scanf-1.c.
+       * gcc.dg/c90-scanf-2.c: Rename to gcc.dg/format/c90-scanf-2.c.
+       * gcc.dg/c90-scanf-3.c: Rename to gcc.dg/format/c90-scanf-3.c.
+       * gcc.dg/c90-scanf-4.c: Rename to gcc.dg/format/c90-scanf-4.c.
+       * gcc.dg/c94-scanf-1.c: Rename to gcc.dg/format/c94-scanf-1.c.
+       * gcc.dg/c99-scanf-1.c: Rename to gcc.dg/format/c99-scanf-1.c.
+       * gcc.dg/c99-scanf-2.c: Rename to gcc.dg/format/c99-scanf-2.c.
+       * gcc.dg/c99-scanf-3.c: Rename to gcc.dg/format/c99-scanf-3.c.
+       * gcc.dg/c90-strftime-1.c: Rename to gcc.dg/format/c90-strftime-1.c.
+       * gcc.dg/c90-strftime-2.c: Rename to gcc.dg/format/c90-strftime-2.c.
+       * gcc.dg/c99-strftime-1.c: Rename to gcc.dg/format/c99-strftime-1.c.
+       * gcc.dg/c99-strftime-2.c: Rename to gcc.dg/format/c99-strftime-2.c.
+       * gcc.dg/format-array-1.c: Rename to gcc.dg/format/array-1.c.
+       * gcc.dg/format-attr-1.c: Rename to gcc.dg/format/attr-1.c.
+       * gcc.dg/format-branch-1.c: Rename to gcc.dg/format/branch-1.c.
+       * gcc.dg/format-diag-1.c: Rename to gcc.dg/format/diag-1.c.
+       * gcc.dg/format-errmk-1.c: Rename to gcc.dg/format/errmk-1.c.
+       * gcc.dg/format-ext-1.c: Rename to gcc.dg/format/ext-1.c.
+       * gcc.dg/format-ext-2.c: Rename to gcc.dg/format/ext-2.c.
+       * gcc.dg/format-ext-3.c: Rename to gcc.dg/format/ext-3.c.
+       * gcc.dg/format-ext-4.c: Rename to gcc.dg/format/ext-4.c.
+       * gcc.dg/format-ext-5.c: Rename to gcc.dg/format/ext-5.c.
+       * gcc.dg/format-miss-1.c: Rename to gcc.dg/format/miss-1.c.
+       * gcc.dg/format-miss-2.c: Rename to gcc.dg/format/miss-2.c.
+       * gcc.dg/format-no-exargs-1.c: Rename to gcc.dg/format/no-exargs-1.c.
+       * gcc.dg/format-no-y2k-1.c: Rename to gcc.dg/format/no-y2k-1.c.
+       * gcc.dg/format-nonlit-1.c: Rename to gcc.dg/format/nonlit-1.c.
+       * gcc.dg/format-nonlit-2.c: Rename to gcc.dg/format/nonlit-2.c.
+       * gcc.dg/format-nonlit-3.c: Rename to gcc.dg/format/nonlit-3.c.
+       * gcc.dg/format-sec-1.c: Rename to gcc.dg/format/sec-1.c.
+       * gcc.dg/format-strfmon-1.c: Rename to gcc.dg/format/strfmon-1.c.
+       * gcc.dg/format-va-1.c: Rename to gcc.dg/format/va-1.c.
+       * gcc.dg/format-warnll-1.c: Rename to gcc.dg/format/warnll-1.c.
+       * gcc.dg/format-xopen-1.c: Rename to gcc.dg/format/xopen-1.c.
+       * gcc.dg/formatz-1.c: Rename to gcc.dg/format/z-1.c.
+
 2001-01-05  Alexandre Oliva  <aoliva@redhat.com>
 
        * gcc.c-torture/execute/991228-1.c: Take word endianness into
diff --git a/gcc/testsuite/gcc.dg/c90-printf-1.c b/gcc/testsuite/gcc.dg/c90-printf-1.c
deleted file mode 100644 (file)
index 5058066..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-/* Test for printf formats.  Formats using C90 features, including cases
-   where C90 specifies some aspect of the format to be ignored or where
-   the behaviour is undefined.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
-
-typedef __WCHAR_TYPE__ wchar_t;
-
-#ifndef __WINT_TYPE__
-#define __WINT_TYPE__ unsigned int
-#endif
-typedef __WINT_TYPE__ wint_t;
-
-__extension__ typedef long long int llong;
-__extension__ typedef unsigned long long int ullong;
-
-extern int printf (const char *, ...);
-
-#define NULL ((void *)0)
-
-void
-foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
-     int *n, short int *hn, long int l, unsigned long int ul,
-     long int *ln, long double ld, wint_t lc, wchar_t *ls, llong ll,
-     ullong ull, unsigned int *un, const int *cn, signed char *ss,
-     unsigned char *us, const signed char *css, unsigned int u1,
-     unsigned int u2)
-{
-  /* See ISO/IEC 9899:1990 (E) subclause 7.9.6.1 (pages 131-134).  */
-  /* Basic sanity checks for the different components of a format.  */
-  printf ("%d\n", i);
-  printf ("%+d\n", i);
-  printf ("%3d\n", i);
-  printf ("%-3d\n", i);
-  printf ("%.7d\n", i);
-  printf ("%+9.4d\n", i);
-  printf ("%.3ld\n", l);
-  printf ("%*d\n", i1, i);
-  printf ("%.*d\n", i2, i);
-  printf ("%*.*ld\n", i1, i2, l);
-  printf ("%d %lu\n", i, ul);
-  /* GCC has objected to the next one in the past, but it is a valid way
-     of specifying zero precision.
-  */
-  printf ("%.e\n", d); /* { dg-bogus "precision" "bogus precision warning" } */
-  /* Bogus use of width.  */
-  printf ("%5n\n", n); /* { dg-warning "width" "width with %n" } */
-  /* Erroneous, ignored or pointless constructs with precision.  */
-  /* Whether negative values for precision may be included in the format
-     string is not entirely clear; presume not, following Clive Feather's
-     proposed resolution to DR#220 against C99.  In any case, such a
-     construct should be warned about.
-  */
-  printf ("%.-5d\n", i); /* { dg-warning "format|precision" "negative precision warning" } */
-  printf ("%.-*d\n", i); /* { dg-warning "format" "broken %.-*d format" } */
-  printf ("%.3c\n", i); /* { dg-warning "precision" "precision with %c" } */
-  printf ("%.3p\n", p); /* { dg-warning "precision" "precision with %p" } */
-  printf ("%.3n\n", n); /* { dg-warning "precision" "precision with %n" } */
-  /* Valid and invalid %% constructions.  Some of the warning messages
-     are non-optimal, but they do detect the errorneous nature of the
-     format string.
-  */
-  printf ("%%");
-  printf ("%.3%"); /* { dg-warning "format" "bogus %%" } */
-  printf ("%-%"); /* { dg-warning "format" "bogus %%" } */
-  printf ("%-%\n"); /* { dg-warning "format" "bogus %%" } */
-  printf ("%5%\n"); /* { dg-warning "format" "bogus %%" } */
-  printf ("%h%\n"); /* { dg-warning "format" "bogus %%" } */
-  /* Valid and invalid %h, %l, %L constructions.  */
-  printf ("%hd", i);
-  printf ("%hi", i);
-  /* Strictly, these parameters should be int or unsigned int according to
-     what unsigned short promotes to.  However, GCC ignores sign
-     differences in format checking here, and this is relied on to get the
-     correct checking without print_char_table needing to know whether
-     int and short are the same size.
-  */
-  printf ("%ho%hu%hx%hX", u, u, u, u);
-  printf ("%hn", hn);
-  printf ("%hf", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%he", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hE", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hg", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hG", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hc", i); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hs", s); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hp", p); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%h"); /* { dg-warning "conversion lacks type" "bare %h" } */
-  printf ("%h."); /* { dg-warning "conversion" "bogus %h." } */
-  printf ("%ld%li%lo%lu%lx%lX", l, l, ul, ul, ul, ul);
-  printf ("%ln", ln);
-  printf ("%lf", d); /* { dg-warning "length|C" "bad use of %l" } */
-  printf ("%le", d); /* { dg-warning "length|C" "bad use of %l" } */
-  printf ("%lE", d); /* { dg-warning "length|C" "bad use of %l" } */
-  printf ("%lg", d); /* { dg-warning "length|C" "bad use of %l" } */
-  printf ("%lG", d); /* { dg-warning "length|C" "bad use of %l" } */
-  printf ("%lp", p); /* { dg-warning "length|C" "bad use of %l" } */
-  /* These next two were added in C94, but should be objected to in C90.
-     For the first one, GCC has wanted wchar_t instead of the correct C94
-     and C99 wint_t.
-  */
-  printf ("%lc", lc); /* { dg-warning "length|C" "C90 bad use of %l" } */
-  printf ("%ls", ls); /* { dg-warning "length|C" "C90 bad use of %l" } */
-  /* These uses of %L are legitimate, though GCC has wrongly warned for
-     them in the past.
-  */
-  printf ("%Le%LE%Lf%Lg%LG", ld, ld, ld, ld, ld);
-  /* These next six are accepted by GCC as referring to long long,
-     but -pedantic correctly warns.
-  */
-  printf ("%Ld", ll); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%Li", ll); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%Lo", ull); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%Lu", ull); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%Lx", ull); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%LX", ull); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%Lc", i); /* { dg-warning "length" "bad use of %L" } */
-  printf ("%Ls", s); /* { dg-warning "length" "bad use of %L" } */
-  printf ("%Lp", p); /* { dg-warning "length" "bad use of %L" } */
-  printf ("%Ln", n); /* { dg-warning "length" "bad use of %L" } */
-  /* Valid uses of each bare conversion.  */
-  printf ("%d%i%o%u%x%X%f%e%E%g%G%c%s%p%n%%", i, i, u, u, u, u, d, d, d, d, d,
-         i, s, p, n);
-  /* Uses of the - flag (valid on all non-%, non-n conversions).  */
-  printf ("%-d%-i%-o%-u%-x%-X%-f%-e%-E%-g%-G%-c%-s%-p", i, i, u, u, u, u,
-         d, d, d, d, d, i, s, p);
-  printf ("%-n", n); /* { dg-warning "flag" "bad use of %-n" } */
-  /* Uses of the + flag (valid on signed conversions only).  */
-  printf ("%+d%+i%+f%+e%+E%+g%+G\n", i, i, d, d, d, d, d);
-  printf ("%+o", u); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+u", u); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+x", u); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+X", u); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+c", i); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+s", s); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+p", p); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+n", n); /* { dg-warning "flag" "bad use of + flag" } */
-  /* Uses of the space flag (valid on signed conversions only, and ignored
-     with +).
-  */
-  printf ("% +d", i); /* { dg-warning "use of both|ignored" "use of space and + flags" } */
-  printf ("%+ d", i); /* { dg-warning "use of both|ignored" "use of space and + flags" } */
-  printf ("% d% i% f% e% E% g% G\n", i, i, d, d, d, d, d);
-  printf ("% o", u); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% u", u); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% x", u); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% X", u); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% c", i); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% s", s); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% p", p); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% n", n); /* { dg-warning "flag" "bad use of space flag" } */
-  /* Uses of the # flag.  */
-  printf ("%#o%#x%#X%#e%#E%#f%#g%#G", u, u, u, d, d, d, d, d);
-  printf ("%#d", i); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#i", i); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#u", u); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#c", i); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#s", s); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#p", p); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#n", n); /* { dg-warning "flag" "bad use of # flag" } */
-  /* Uses of the 0 flag.  */
-  printf ("%08d%08i%08o%08u%08x%08X%08e%08E%08f%08g%08G", i, i, u, u, u, u,
-         d, d, d, d, d);
-  printf ("%0c", i); /* { dg-warning "flag" "bad use of 0 flag" } */
-  printf ("%0s", s); /* { dg-warning "flag" "bad use of 0 flag" } */
-  printf ("%0p", p); /* { dg-warning "flag" "bad use of 0 flag" } */
-  printf ("%0n", n); /* { dg-warning "flag" "bad use of 0 flag" } */
-  /* 0 flag ignored with precision for certain types, not others.  */
-  printf ("%08.5d", i); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5i", i); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5o", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5u", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5x", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5X", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5f%08.5e%08.5E%08.5g%08.5G", d, d, d, d, d);
-  /* 0 flag ignored with - flag.  */
-  printf ("%-08d", i); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08i", i); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08o", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08u", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08x", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08X", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08e", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08E", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08f", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08g", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08G", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  /* Various tests of bad argument types.  */
-  printf ("%d", l); /* { dg-warning "format" "bad argument types" } */
-  printf ("%*.*d", l, i2, i); /* { dg-warning "field" "bad * argument types" } */
-  printf ("%*.*d", i1, l, i); /* { dg-warning "field" "bad * argument types" } */
-  printf ("%ld", i); /* { dg-warning "format" "bad argument types" } */
-  printf ("%s", n); /* { dg-warning "format" "bad argument types" } */
-  printf ("%p", i); /* { dg-warning "format" "bad argument types" } */
-  printf ("%n", p); /* { dg-warning "format" "bad argument types" } */
-  /* With -pedantic, we want some further checks for pointer targets:
-     %p should allow only pointers to void (possibly qualified) and
-     to character types (possibly qualified), but not function pointers
-     or pointers to other types.  (Whether, in fact, character types are
-     allowed here is unclear; see thread on comp.std.c, July 2000 for
-     discussion of the requirements of rules on identical representation,
-     and of the application of the as if rule with the new va_arg
-     allowances in C99 to printf.)  Likewise, we should warn if
-     pointer targets differ in signedness, except in some circumstances
-     for character pointers.  (In C99 we should consider warning for
-     char * or unsigned char * being passed to %hhn, even if strictly
-     legitimate by the standard.)
-  */
-  printf ("%p", foo); /* { dg-warning "format" "bad argument types" } */
-  printf ("%n", un); /* { dg-warning "format" "bad argument types" } */
-  printf ("%p", n); /* { dg-warning "format" "bad argument types" } */
-  /* Allow character pointers with %p.  */
-  printf ("%p%p%p%p", s, ss, us, css);
-  /* %s allows any character type.  */
-  printf ("%s%s%s%s", s, ss, us, css);
-  /* Warning for void * arguments for %s is GCC's historical behaviour,
-     and seems useful to keep, even if some standard versions might be
-     read to permit it.
-  */
-  printf ("%s", p); /* { dg-warning "format" "bad argument types" } */
-  /* The historical behaviour is to allow signed / unsigned types
-     interchangably as arguments.  For values representable in both types,
-     such usage may be correct.  For now preserve the behaviour of GCC
-     in such cases.
-  */
-  printf ("%d", u);
-  /* Also allow the same for width and precision arguments.  In the past,
-     GCC has been inconsistent and allowed unsigned for width but not
-     precision.
-  */
-  printf ("%*.*d", u1, u2, i);
-  /* Wrong number of arguments.  */
-  printf ("%d%d", i); /* { dg-warning "arguments" "wrong number of args" } */
-  printf ("%d", i, i); /* { dg-warning "arguments" "wrong number of args" } */
-  /* Miscellaneous bogus constructions.  */
-  printf (""); /* { dg-warning "zero-length" "warning for empty format" } */
-  printf ("\0"); /* { dg-warning "embedded" "warning for embedded NUL" } */
-  printf ("%d\0", i); /* { dg-warning "embedded" "warning for embedded NUL" } */
-  printf ("%d\0%d", i, i); /* { dg-warning "embedded|too many" "warning for embedded NUL" } */
-  printf (NULL); /* { dg-warning "null" "null format string warning" } */
-  printf ("%"); /* { dg-warning "trailing" "trailing % warning" } */
-  printf ("%++d", i); /* { dg-warning "repeated" "repeated flag warning" } */
-  printf ("%n", cn); /* { dg-warning "constant" "%n with const" } */
-  printf ((const char *)L"foo"); /* { dg-warning "wide" "wide string" } */
-  printf ("%n", (int *)0); /* { dg-warning "null" "%n with NULL" } */
-  printf ("%s", (char *)0); /* { dg-warning "null" "%s with NULL" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c90-printf-2.c b/gcc/testsuite/gcc.dg/c90-printf-2.c
deleted file mode 100644 (file)
index 1f8c544..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Test for printf formats.  Formats using C99 features should be rejected
-   outside of C99 mode.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
-
-typedef __SIZE_TYPE__ size_t;
-typedef __PTRDIFF_TYPE__ ptrdiff_t;
-
-__extension__ typedef long long int llong;
-
-/* This next definition is a kludge.  When GCC has a <stdint.h> it
-   should be used.
-*/
-/* (T *) if E is zero, (void *) otherwise.  */
-#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E))
-
-/* (T *) if E is nonzero, (void *) otherwise.  */
-#define type_if(T, E) type_if_not(T, !(E))
-
-/* Combine pointer types, all but one (void *).  */
-#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0)
-#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3))
-
-#define maybe_int_ptr type_if(int, sizeof(int) == sizeof(llong))
-#define maybe_long_ptr type_if(long, sizeof(long) == sizeof(llong) && sizeof(long) > sizeof(int))
-#define maybe_long_long_ptr type_if(llong, sizeof(llong) > sizeof(long))
-
-#define intmax_type_ptr type_comb3(maybe_int_ptr, maybe_long_ptr, maybe_long_long_ptr)
-
-typedef __typeof__(*((intmax_type_ptr)0)) intmax_t;
-
-extern int printf (const char *, ...);
-
-void
-foo (int i, double d, llong ll, intmax_t j, size_t z, ptrdiff_t t)
-{
-  /* Some tests already in c90-printf-1.c, e.g. %lf.  */
-  /* The widths hh, ll, j, z, t are new.  */
-  printf ("%hhd", i); /* { dg-warning "length|C" "%hh in C90" } */
-  printf ("%lld", ll); /* { dg-warning "length|C" "%ll in C90" } */
-  printf ("%jd", j); /* { dg-warning "length|C" "%j in C90" } */
-  printf ("%zu", z); /* { dg-warning "length|C" "%z in C90" } */
-  printf ("%td", t); /* { dg-warning "length|C" "%t in C90" } */
-  /* The formats F, a, A are new.  */
-  printf ("%F", d); /* { dg-warning "C" "%F in C90" } */
-  printf ("%a", d); /* { dg-warning "C" "%a in C90" } */
-  printf ("%A", d); /* { dg-warning "C" "%A in C90" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c90-printf-3.c b/gcc/testsuite/gcc.dg/c90-printf-3.c
deleted file mode 100644 (file)
index 119cdee..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Test for printf formats.  Test that the C90 functions get their default
-   attributes in strict C90 mode, but the C99 and gettext functions
-   do not.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
-
-/* This may not be correct in the particular case, but allows the
-   prototypes to be declared, and we don't try to link.
-*/
-typedef struct _FILE FILE;
-extern FILE *stdout;
-
-typedef __SIZE_TYPE__ size_t;
-typedef __builtin_va_list va_list;
-
-extern int fprintf (FILE *, const char *, ...);
-extern int printf (const char *, ...);
-extern int sprintf (char *, const char *, ...);
-extern int vfprintf (FILE *, const char *, va_list);
-extern int vprintf (const char *, va_list);
-extern int vsprintf (char *, const char *, va_list);
-
-extern int snprintf (char *, size_t, const char *, ...);
-extern int vsnprintf (char *, size_t, const char *, va_list);
-
-extern char *gettext (const char *);
-extern char *dgettext (const char *, const char *);
-extern char *dcgettext (const char *, const char *, int);
-
-void
-foo (int i, char *s, size_t n, va_list v0, va_list v1, va_list v2, va_list v3,
-     va_list v4, va_list v5, va_list v6, va_list v7, va_list v8)
-{
-  fprintf (stdout, "%d", i);
-  fprintf (stdout, "%ld", i); /* { dg-warning "format" "fprintf" } */
-  printf ("%d", i);
-  printf ("%ld", i); /* { dg-warning "format" "printf" } */
-  sprintf (s, "%d", i);
-  sprintf (s, "%ld", i); /* { dg-warning "format" "sprintf" } */
-  vfprintf (stdout, "%d", v0);
-  vfprintf (stdout, "%Y", v1); /* { dg-warning "format" "vfprintf" } */
-  vprintf ("%d", v2);
-  vprintf ("%Y", v3); /* { dg-warning "format" "vprintf" } */
-  /* The following used to give a bogus warning.  */
-  vprintf ("%*.*d", v8);
-  vsprintf (s, "%d", v4);
-  vsprintf (s, "%Y", v5); /* { dg-warning "format" "vsprintf" } */
-  snprintf (s, n, "%d", i);
-  snprintf (s, n, "%ld", i);
-  vsnprintf (s, n, "%d", v6);
-  vsnprintf (s, n, "%Y", v7);
-  printf (gettext ("%d"), i);
-  printf (gettext ("%ld"), i);
-  printf (dgettext ("", "%d"), i);
-  printf (dgettext ("", "%ld"), i);
-  printf (dcgettext ("", "%d", 0), i);
-  printf (dcgettext ("", "%ld", 0), i);
-}
diff --git a/gcc/testsuite/gcc.dg/c90-scanf-1.c b/gcc/testsuite/gcc.dg/c90-scanf-1.c
deleted file mode 100644 (file)
index 922a7a7..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Test for scanf formats.  Formats using C90 features, including cases
-   where C90 specifies some aspect of the format to be ignored or where
-   the behaviour is undefined.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
-
-typedef __WCHAR_TYPE__ wchar_t;
-
-__extension__ typedef long long int llong;
-__extension__ typedef unsigned long long int ullong;
-
-extern int scanf (const char *, ...);
-
-#define NULL ((void *)0)
-
-void
-foo (int *ip, unsigned int *uip, short int *hp, unsigned short int *uhp,
-     long int *lp, unsigned long int *ulp, float *fp, double *dp,
-     long double *ldp, char *s, signed char *ss, unsigned char *us,
-     void **pp, int *n, llong *llp, ullong *ullp, wchar_t *ls,
-     const int *cip, const int *cn, const char *cs, const void **ppc,
-     void *const *pcp, short int *hn, long int *ln, void *p, char **sp,
-     volatile void *ppv)
-{
-  /* See ISO/IEC 9899:1990 (E) subclause 7.9.6.2 (pages 134-138).  */
-  /* Basic sanity checks for the different components of a format.  */
-  scanf ("%d", ip);
-  scanf ("%*d");
-  scanf ("%3d", ip);
-  scanf ("%hd", hp);
-  scanf ("%3ld", lp);
-  scanf ("%*3d");
-  scanf ("%d %ld", ip, lp);
-  /* Valid and invalid %% constructions.  */
-  scanf ("%%");
-  scanf ("%*%"); /* { dg-warning "format" "bogus %%" } */
-  scanf ("%*%\n"); /* { dg-warning "format" "bogus %%" } */
-  scanf ("%4%"); /* { dg-warning "format" "bogus %%" } */
-  scanf ("%4%\n"); /* { dg-warning "format" "bogus %%" } */
-  scanf ("%h%"); /* { dg-warning "format" "bogus %%" } */
-  scanf ("%h%\n"); /* { dg-warning "format" "bogus %%" } */
-  /* Valid, invalid and silly assignment-suppression constructions.  */
-  scanf ("%*d%*i%*o%*u%*x%*X%*e%*E%*f%*g%*G%*s%*[abc]%*c%*p");
-  scanf ("%*2d%*8s%*3c");
-  scanf ("%*n", n); /* { dg-warning "suppress" "suppression of %n" } */
-  scanf ("%*hd"); /* { dg-warning "together" "suppression with length" } */
-  /* Valid, invalid and silly width constructions.  */
-  scanf ("%2d%3i%4o%5u%6x%7X%8e%9E%10f%11g%12G%13s%14[abc]%15c%16p",
-        ip, ip, uip, uip, uip, uip, fp, fp, fp, fp, fp, s, s, s, pp);
-  scanf ("%0d", ip); /* { dg-warning "width" "warning for zero width" } */
-  scanf ("%3n", n); /* { dg-warning "width" "width with %n" } */
-  /* Valid and invalid %h, %l, %L constructions.  */
-  scanf ("%hd%hi%ho%hu%hx%hX%hn", hp, hp, uhp, uhp, uhp, uhp, hn);
-  scanf ("%he", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hE", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hf", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hg", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hG", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hs", s); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%h[ac]", s); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hc", s); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hp", pp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%h"); /* { dg-warning "conversion lacks type" "bare %h" } */
-  scanf ("%h."); /* { dg-warning "conversion" "bogus %h" } */
-  scanf ("%ld%li%lo%lu%lx%lX%ln", lp, lp, ulp, ulp, ulp, ulp, ln);
-  scanf ("%le%lE%lf%lg%lG", dp, dp, dp, dp, dp);
-  scanf ("%lp", pp); /* { dg-warning "length" "bad use of %l" } */
-  /* These next three formats were added in C94.  */
-  scanf ("%ls", ls); /* { dg-warning "length|C" "bad use of %l" } */
-  scanf ("%l[ac]", ls); /* { dg-warning "length|C" "bad use of %l" } */
-  scanf ("%lc", ls); /* { dg-warning "length|C" "bad use of %l" } */
-  scanf ("%Le%LE%Lf%Lg%LG", ldp, ldp, ldp, ldp, ldp);
-  scanf ("%Ld", llp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%Li", llp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%Lo", ullp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%Lu", ullp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%Lx", ullp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%LX", ullp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%Ls", s); /* { dg-warning "length" "bad use of %L" } */
-  scanf ("%L[ac]", s); /* { dg-warning "length" "bad use of %L" } */
-  scanf ("%Lc", s); /* { dg-warning "length" "bad use of %L" } */
-  scanf ("%Lp", pp); /* { dg-warning "length" "bad use of %L" } */
-  scanf ("%Ln", n); /* { dg-warning "length" "bad use of %L" } */
-  /* Valid uses of each bare conversion.  */
-  scanf ("%d%i%o%u%x%X%e%E%f%g%G%s%[abc]%c%p%n%%", ip, ip, uip, uip, uip,
-        uip, fp, fp, fp, fp, fp, s, s, s, pp, n);
-  /* Allow other character pointers with %s, %c, %[].  */
-  scanf ("%2s%3s%4c%5c%6[abc]%7[abc]", ss, us, ss, us, ss, us);
-  /* Further tests for %[].  */
-  scanf ("%[%d]%d", s, ip);
-  scanf ("%[^%d]%d", s, ip);
-  scanf ("%[]%d]%d", s, ip);
-  scanf ("%[^]%d]%d", s, ip);
-  scanf ("%[%d]%d", s, ip);
-  scanf ("%[]abcd", s); /* { dg-warning "no closing" "incomplete scanset" } */
-  /* Various tests of bad argument types.  Some of these are only pedantic
-     warnings.
-  */
-  scanf ("%d", lp); /* { dg-warning "format" "bad argument types" } */
-  scanf ("%d", uip); /* { dg-warning "format" "bad argument types" } */
-  scanf ("%d", pp); /* { dg-warning "format" "bad argument types" } */
-  scanf ("%p", ppc); /* { dg-warning "format" "bad argument types" } */
-  scanf ("%p", ppv); /* { dg-warning "format" "bad argument types" } */
-  scanf ("%s", n); /* { dg-warning "format" "bad argument types" } */
-  scanf ("%s", p); /* { dg-warning "format" "bad argument types" } */
-  scanf ("%p", p); /* { dg-warning "format" "bad argument types" } */
-  scanf ("%p", sp); /* { dg-warning "format" "bad argument types" } */
-  /* Tests for writing into constant values.  */
-  scanf ("%d", cip); /* { dg-warning "constant" "%d writing into const" } */
-  scanf ("%n", cn); /* { dg-warning "constant" "%n writing into const" } */
-  scanf ("%s", cs); /* { dg-warning "constant" "%s writing into const" } */
-  scanf ("%p", pcp); /* { dg-warning "constant" "%p writing into const" } */
-  /* Wrong number of arguments.  */
-  scanf ("%d%d", ip); /* { dg-warning "arguments" "wrong number of args" } */
-  scanf ("%d", ip, ip); /* { dg-warning "arguments" "wrong number of args" } */
-  /* Miscellaneous bogus constructions.  */
-  scanf (""); /* { dg-warning "zero-length" "warning for empty format" } */
-  scanf ("\0"); /* { dg-warning "embedded" "warning for embedded NUL" } */
-  scanf ("%d\0", ip); /* { dg-warning "embedded" "warning for embedded NUL" } */
-  scanf ("%d\0%d", ip, ip); /* { dg-warning "embedded|too many" "warning for embedded NUL" } */
-  scanf (NULL); /* { dg-warning "null" "null format string warning" } */
-  scanf ("%"); /* { dg-warning "trailing" "trailing % warning" } */
-  scanf ("%d", (int *)0); /* { dg-warning "null" "writing into NULL" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c90-scanf-2.c b/gcc/testsuite/gcc.dg/c90-scanf-2.c
deleted file mode 100644 (file)
index 786acdd..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Test for scanf formats.  Formats using C99 features should be rejected
-   outside of C99 mode.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
-
-typedef __SIZE_TYPE__ size_t;
-typedef __PTRDIFF_TYPE__ ptrdiff_t;
-
-__extension__ typedef long long int llong;
-
-/* This next definition is a kludge.  When GCC has a <stdint.h> it
-   should be used.
-*/
-/* (T *) if E is zero, (void *) otherwise.  */
-#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E))
-
-/* (T *) if E is nonzero, (void *) otherwise.  */
-#define type_if(T, E) type_if_not(T, !(E))
-
-/* Combine pointer types, all but one (void *).  */
-#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0)
-#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3))
-
-#define maybe_int_ptr type_if(int, sizeof(int) == sizeof(llong))
-#define maybe_long_ptr type_if(long, sizeof(long) == sizeof(llong) && sizeof(long) > sizeof(int))
-#define maybe_long_long_ptr type_if(llong, sizeof(llong) > sizeof(long))
-
-#define intmax_type_ptr type_comb3(maybe_int_ptr, maybe_long_ptr, maybe_long_long_ptr)
-
-typedef __typeof__(*((intmax_type_ptr)0)) intmax_t;
-
-extern int scanf (const char *, ...);
-
-void
-foo (signed char *hhp, float *fp, llong *llp, intmax_t *jp,
-     size_t *zp, ptrdiff_t *tp)
-{
-  /* Some tests already in c90-scanf-1.c.  */
-  /* The widths hh, ll, j, z, t are new.  */
-  scanf ("%hhd", hhp); /* { dg-warning "length|C" "%hh in C90" } */
-  scanf ("%lld", llp); /* { dg-warning "length|C" "%ll in C90" } */
-  scanf ("%jd", jp); /* { dg-warning "length|C" "%j in C90" } */
-  scanf ("%zu", zp); /* { dg-warning "length|C" "%z in C90" } */
-  scanf ("%td", tp); /* { dg-warning "length|C" "%t in C90" } */
-  /* The formats F, a, A are new.  */
-  scanf ("%F", fp); /* { dg-warning "C" "%F in C90" } */
-  scanf ("%a", fp); /* { dg-warning "C" "%a in C90" } */
-  scanf ("%A", fp); /* { dg-warning "C" "%A in C90" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c90-scanf-3.c b/gcc/testsuite/gcc.dg/c90-scanf-3.c
deleted file mode 100644 (file)
index 147a222..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Test for scanf formats.  Formats using extensions to the standard
-   should be rejected in strict pedantic mode.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
-
-typedef __WCHAR_TYPE__ wchar_t;
-
-extern int scanf (const char *, ...);
-
-void
-foo (char **sp, wchar_t **lsp)
-{
-  /* %a formats for allocation, only recognised in C90 mode, are a
-     GNU extension.
-  */
-  scanf ("%as", sp); /* { dg-warning "C" "%as" } */
-  scanf ("%aS", lsp); /* { dg-warning "C" "%aS" } */
-  scanf ("%a[bcd]", sp); /* { dg-warning "C" "%a[]" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c90-scanf-4.c b/gcc/testsuite/gcc.dg/c90-scanf-4.c
deleted file mode 100644 (file)
index 3bbe66e..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Test for scanf formats.  Test that the C90 functions get their default
-   attributes in strict C90 mode, but the C99 and gettext functions
-   do not.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
-
-/* This may not be correct in the particular case, but allows the
-   prototypes to be declared, and we don't try to link.
-*/
-typedef struct _FILE FILE;
-extern FILE *stdin;
-
-typedef __builtin_va_list va_list;
-
-extern int fscanf (FILE *, const char *, ...);
-extern int scanf (const char *, ...);
-extern int sscanf (const char *, const char *, ...);
-
-extern int vfscanf (FILE *, const char *, va_list);
-extern int vscanf (const char *, va_list);
-extern int vsscanf (const char *, const char *, va_list);
-
-extern char *gettext (const char *);
-extern char *dgettext (const char *, const char *);
-extern char *dcgettext (const char *, const char *, int);
-
-void
-foo (int *ip, char *s, va_list v0, va_list v1, va_list v2, va_list v3,
-     va_list v4, va_list v5)
-{
-  fscanf (stdin, "%d", ip);
-  fscanf (stdin, "%ld", ip); /* { dg-warning "format" "fscanf" } */
-  scanf ("%d", ip);
-  scanf ("%ld", ip); /* { dg-warning "format" "scanf" } */
-  sscanf (s, "%d", ip);
-  sscanf (s, "%ld", ip); /* { dg-warning "format" "sscanf" } */
-  vfscanf (stdin, "%d", v0);
-  vfscanf (stdin, "%Y", v1);
-  vscanf ("%d", v2);
-  vscanf ("%Y", v3);
-  vsscanf (s, "%d", v4);
-  vsscanf (s, "%Y", v5);
-  scanf (gettext ("%d"), ip);
-  scanf (gettext ("%ld"), ip);
-  scanf (dgettext ("", "%d"), ip);
-  scanf (dgettext ("", "%ld"), ip);
-  scanf (dcgettext ("", "%d", 0), ip);
-  scanf (dcgettext ("", "%ld", 0), ip);
-}
diff --git a/gcc/testsuite/gcc.dg/c90-strftime-1.c b/gcc/testsuite/gcc.dg/c90-strftime-1.c
deleted file mode 100644 (file)
index 6a13d5e..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Test for strftime formats.  Formats using C90 features.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
-
-typedef __SIZE_TYPE__ size_t;
-
-struct tm;
-
-extern size_t strftime (char *, size_t, const char *, const struct tm *);
-
-void
-foo (char *s, size_t m, const struct tm *tp)
-{
-  /* See ISO/IEC 9899:1990 (E) subclause 7.12.3.5 (pages 174-175).  */
-  /* Formats which are Y2K-compliant (no 2-digit years).  */
-  strftime (s, m, "%a%A%b%B%d%H%I%j%m%M%p%S%U%w%W%X%Y%Z%%", tp);
-  /* Formats with 2-digit years.  */
-  strftime (s, m, "%y", tp); /* { dg-warning "only last 2" "2-digit year" } */
-  /* Formats with 2-digit years in some locales.  */
-  strftime (s, m, "%c", tp); /* { dg-warning "some locales" "2-digit year" } */
-  strftime (s, m, "%x", tp); /* { dg-warning "some locales" "2-digit year" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c90-strftime-2.c b/gcc/testsuite/gcc.dg/c90-strftime-2.c
deleted file mode 100644 (file)
index 4d6c289..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Test for strftime formats.  Rejection of formats using C99 features in
-   pedantic C90 mode.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
-
-typedef __SIZE_TYPE__ size_t;
-
-struct tm;
-
-extern size_t strftime (char *, size_t, const char *, const struct tm *);
-
-void
-foo (char *s, size_t m, const struct tm *tp)
-{
-  strftime (s, m, "%C", tp); /* { dg-warning "C" "%C not in C90" } */
-  strftime (s, m, "%D", tp); /* { dg-warning "C" "%D not in C90" } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 17 } */
-  strftime (s, m, "%e", tp); /* { dg-warning "C" "%e not in C90" } */
-  strftime (s, m, "%F", tp); /* { dg-warning "C" "%F not in C90" } */
-  strftime (s, m, "%g", tp); /* { dg-warning "C" "%g not in C90" } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 21 } */
-  strftime (s, m, "%G", tp); /* { dg-warning "C" "%G not in C90" } */
-  strftime (s, m, "%h", tp); /* { dg-warning "C" "%h not in C90" } */
-  strftime (s, m, "%n", tp); /* { dg-warning "C" "%n not in C90" } */
-  strftime (s, m, "%r", tp); /* { dg-warning "C" "%r not in C90" } */
-  strftime (s, m, "%R", tp); /* { dg-warning "C" "%R not in C90" } */
-  strftime (s, m, "%t", tp); /* { dg-warning "C" "%t not in C90" } */
-  strftime (s, m, "%T", tp); /* { dg-warning "C" "%T not in C90" } */
-  strftime (s, m, "%u", tp); /* { dg-warning "C" "%u not in C90" } */
-  strftime (s, m, "%V", tp); /* { dg-warning "C" "%V not in C90" } */
-  strftime (s, m, "%z", tp); /* { dg-warning "C" "%z not in C90" } */
-  strftime (s, m, "%EX", tp); /* { dg-warning "C" "%E not in C90" } */
-  strftime (s, m, "%OW", tp); /* { dg-warning "C" "%O not in C90" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c94-printf-1.c b/gcc/testsuite/gcc.dg/c94-printf-1.c
deleted file mode 100644 (file)
index 449a342..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Test for printf formats.  Changes in C94 to C90.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:199409 -pedantic -Wformat" } */
-
-typedef __WCHAR_TYPE__ wchar_t;
-
-#ifndef __WINT_TYPE__
-#define __WINT_TYPE__ unsigned int
-#endif
-typedef __WINT_TYPE__ wint_t;
-
-extern int printf (const char *, ...);
-
-void
-foo (wint_t lc, wchar_t *ls)
-{
-  /* See ISO/IEC 9899:1990 (E) subclause 7.9.6.1 (pages 131-134),
-     as amended by ISO/IEC 9899:1990/Amd.1:1995 (E) (pages 4-5).
-     We do not repeat here all the C90 format checks, but just verify
-     that %ls and %lc are accepted without warning.
-  */
-  printf ("%lc", lc);
-  printf ("%ls", ls);
-}
diff --git a/gcc/testsuite/gcc.dg/c94-scanf-1.c b/gcc/testsuite/gcc.dg/c94-scanf-1.c
deleted file mode 100644 (file)
index 884cd28..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Test for scanf formats.  Changes in C94 to C90.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:199409 -pedantic -Wformat" } */
-
-typedef __WCHAR_TYPE__ wchar_t;
-
-extern int scanf (const char *, ...);
-
-void
-foo (wchar_t *ls)
-{
-  /* See ISO/IEC 9899:1990 (E) subclause 7.9.6.2 (pages 134-138),
-     as amended by ISO/IEC 9899:1990/Amd.1:1995 (E) (pages 5-6).
-     We do not repeat here all the C90 format checks, but just verify
-     that %ls, %lc, %l[] are accepted without warning.
-  */
-  scanf ("%lc%ls%l[abc]", ls, ls, ls);
-}
diff --git a/gcc/testsuite/gcc.dg/c99-printf-1.c b/gcc/testsuite/gcc.dg/c99-printf-1.c
deleted file mode 100644 (file)
index 179ea6e..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/* Test for printf formats.  Formats using C99 features, including cases
-   where C99 specifies some aspect of the format to be ignored or where
-   the behaviour is undefined.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
-
-typedef __WCHAR_TYPE__ wchar_t;
-typedef __WINT_TYPE__ wint_t;
-typedef __SIZE_TYPE__ size_t;
-typedef __PTRDIFF_TYPE__ ptrdiff_t;
-
-/* Kludge to get signed type corresponding to size_t.  */
-#define unsigned signed
-typedef __SIZE_TYPE__ signed_size_t;
-#undef unsigned
-
-/* These next definitions are kludges.  When GCC has a <stdint.h> it
-   should be used.
-*/
-#include <limits.h>
-#if INT_MAX == LLONG_MAX
-typedef int intmax_t;
-#elif LONG_MAX == LLONG_MAX
-typedef long intmax_t;
-#else
-typedef long long intmax_t;
-#endif
-#if UINT_MAX == ULLONG_MAX
-typedef unsigned int uintmax_t;
-#elif ULONG_MAX == ULLONG_MAX
-typedef unsigned long uintmax_t;
-#else
-typedef unsigned long long uintmax_t;
-#endif
-
-extern int printf (const char *, ...);
-
-#define NULL ((void *)0)
-
-void
-foo (int i, unsigned int u, double d, char *s, void *p, int *n,
-     long double ld, wint_t lc, wchar_t *ls, long long int ll,
-     unsigned long long int ull, signed char *ss, unsigned char *us,
-     long long int *lln, intmax_t j, uintmax_t uj, intmax_t *jn,
-     size_t z, signed_size_t sz, signed_size_t *zn,
-     ptrdiff_t t, ptrdiff_t *tn)
-{
-  /* See ISO/IEC 9899:1999 (E) subclause 7.19.6.1 (pages 273-281).
-     We do not repeat here most of the checks for correct C90 formats
-     or completely broken formats.
-  */
-  /* Valid and invalid %h, %hh, %l, %ll, %j, %z, %t, %L constructions.  */
-  printf ("%hf", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hF", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%he", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hE", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hg", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hG", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%ha", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hA", d); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hc", i); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hs", s); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hp", p); /* { dg-warning "length" "bad use of %h" } */
-  printf ("%hhd%hhi%hho%hhu%hhx%hhX", i, i, u, u, u, u);
-  printf ("%hhn", ss);
-  printf ("%hhf", d); /* { dg-warning "length" "bad use of %hh" } */
-  printf ("%hhF", d); /* { dg-warning "length" "bad use of %hh" } */
-  printf ("%hhe", d); /* { dg-warning "length" "bad use of %hh" } */
-  printf ("%hhE", d); /* { dg-warning "length" "bad use of %hh" } */
-  printf ("%hhg", d); /* { dg-warning "length" "bad use of %hh" } */
-  printf ("%hhG", d); /* { dg-warning "length" "bad use of %hh" } */
-  printf ("%hha", d); /* { dg-warning "length" "bad use of %hh" } */
-  printf ("%hhA", d); /* { dg-warning "length" "bad use of %hh" } */
-  printf ("%hhc", i); /* { dg-warning "length" "bad use of %hh" } */
-  printf ("%hhs", s); /* { dg-warning "length" "bad use of %hh" } */
-  printf ("%hhp", p); /* { dg-warning "length" "bad use of %hh" } */
-  printf ("%lc", lc);
-  printf ("%ls", ls);
-  printf ("%lf%lF%le%lE%lg%lG%la%lA", d, d, d, d, d, d, d, d);
-  printf ("%lp", p); /* { dg-warning "length|C" "bad use of %l" } */
-  printf ("%lld%lli%llo%llu%llx%llX", ll, ll, ull, ull, ull, ull);
-  printf ("%lln", lln);
-  printf ("%llf", d); /* { dg-warning "length" "bad use of %ll" } */
-  printf ("%llF", d); /* { dg-warning "length" "bad use of %ll" } */
-  printf ("%lle", d); /* { dg-warning "length" "bad use of %ll" } */
-  printf ("%llE", d); /* { dg-warning "length" "bad use of %ll" } */
-  printf ("%llg", d); /* { dg-warning "length" "bad use of %ll" } */
-  printf ("%llG", d); /* { dg-warning "length" "bad use of %ll" } */
-  printf ("%lla", d); /* { dg-warning "length" "bad use of %ll" } */
-  printf ("%llA", d); /* { dg-warning "length" "bad use of %ll" } */
-  printf ("%llc", i); /* { dg-warning "length" "bad use of %ll" } */
-  printf ("%lls", s); /* { dg-warning "length" "bad use of %ll" } */
-  printf ("%llp", p); /* { dg-warning "length" "bad use of %ll" } */
-  printf ("%jd%ji%jo%ju%jx%jX", j, j, uj, uj, uj, uj); /* { dg-bogus "length" "bogus %j warning" { target *-*-* } } */
-  printf ("%jn", jn); /* { dg-bogus "length" "bogus %j warning" { target *-*-* } } */
-  printf ("%jf", d); /* { dg-warning "length" "bad use of %j" } */
-  printf ("%jF", d); /* { dg-warning "length" "bad use of %j" } */
-  printf ("%je", d); /* { dg-warning "length" "bad use of %j" } */
-  printf ("%jE", d); /* { dg-warning "length" "bad use of %j" } */
-  printf ("%jg", d); /* { dg-warning "length" "bad use of %j" } */
-  printf ("%jG", d); /* { dg-warning "length" "bad use of %j" } */
-  printf ("%ja", d); /* { dg-warning "length" "bad use of %j" } */
-  printf ("%jA", d); /* { dg-warning "length" "bad use of %j" } */
-  printf ("%jc", i); /* { dg-warning "length" "bad use of %j" } */
-  printf ("%js", s); /* { dg-warning "length" "bad use of %j" } */
-  printf ("%jp", p); /* { dg-warning "length" "bad use of %j" } */
-  printf ("%zd%zi%zo%zu%zx%zX", sz, sz, z, z, z, z);
-  printf ("%zn", zn);
-  printf ("%zf", d); /* { dg-warning "length" "bad use of %z" } */
-  printf ("%zF", d); /* { dg-warning "length" "bad use of %z" } */
-  printf ("%ze", d); /* { dg-warning "length" "bad use of %z" } */
-  printf ("%zE", d); /* { dg-warning "length" "bad use of %z" } */
-  printf ("%zg", d); /* { dg-warning "length" "bad use of %z" } */
-  printf ("%zG", d); /* { dg-warning "length" "bad use of %z" } */
-  printf ("%za", d); /* { dg-warning "length" "bad use of %z" } */
-  printf ("%zA", d); /* { dg-warning "length" "bad use of %z" } */
-  printf ("%zc", i); /* { dg-warning "length" "bad use of %z" } */
-  printf ("%zs", s); /* { dg-warning "length" "bad use of %z" } */
-  printf ("%zp", p); /* { dg-warning "length" "bad use of %z" } */
-  printf ("%td%ti%to%tu%tx%tX", t, t, t, t, t, t);
-  printf ("%tn", tn);
-  printf ("%tf", d); /* { dg-warning "length" "bad use of %t" } */
-  printf ("%tF", d); /* { dg-warning "length" "bad use of %t" } */
-  printf ("%te", d); /* { dg-warning "length" "bad use of %t" } */
-  printf ("%tE", d); /* { dg-warning "length" "bad use of %t" } */
-  printf ("%tg", d); /* { dg-warning "length" "bad use of %t" } */
-  printf ("%tG", d); /* { dg-warning "length" "bad use of %t" } */
-  printf ("%ta", d); /* { dg-warning "length" "bad use of %t" } */
-  printf ("%tA", d); /* { dg-warning "length" "bad use of %t" } */
-  printf ("%tc", i); /* { dg-warning "length" "bad use of %t" } */
-  printf ("%ts", s); /* { dg-warning "length" "bad use of %t" } */
-  printf ("%tp", p); /* { dg-warning "length" "bad use of %t" } */
-  printf ("%Le%LE%Lf%LF%Lg%LG%La%LA", ld, ld, ld, ld, ld, ld, ld, ld);
-  /* These next six are accepted by GCC as referring to long long,
-     but -pedantic correctly warns.
-  */
-  printf ("%Ld", ll); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%Li", ll); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%Lo", ull); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%Lu", ull); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%Lx", ull); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%LX", ull); /* { dg-warning "does not support" "bad use of %L" } */
-  printf ("%Lc", i); /* { dg-warning "length" "bad use of %L" } */
-  printf ("%Ls", s); /* { dg-warning "length" "bad use of %L" } */
-  printf ("%Lp", p); /* { dg-warning "length" "bad use of %L" } */
-  printf ("%Ln", n); /* { dg-warning "length" "bad use of %L" } */
-  /* Valid uses of each bare conversion.  */
-  printf ("%d%i%o%u%x%X%f%F%e%E%g%G%a%A%c%s%p%n%%", i, i, u, u, u, u,
-         d, d, d, d, d, d, d, d, i, s, p, n);
-  /* Uses of the - flag (valid on all non-%, non-n conversions).  */
-  printf ("%-d%-i%-o%-u%-x%-X%-f%-F%-e%-E%-g%-G%-a%-A%-c%-s%-p", i, i,
-         u, u, u, u, d, d, d, d, d, d, d, d, i, s, p);
-  printf ("%-n", n); /* { dg-warning "flag" "bad use of %-n" } */
-  /* Uses of the + flag (valid on signed conversions only).  */
-  printf ("%+d%+i%+f%+F%+e%+E%+g%+G%+a%+A\n", i, i, d, d, d, d, d, d, d, d);
-  printf ("%+o", u); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+u", u); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+x", u); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+X", u); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+c", i); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+s", s); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+p", p); /* { dg-warning "flag" "bad use of + flag" } */
-  printf ("%+n", n); /* { dg-warning "flag" "bad use of + flag" } */
-  /* Uses of the space flag (valid on signed conversions only, and ignored
-     with +).
-  */
-  printf ("% +d", i); /* { dg-warning "use of both|ignored" "use of space and + flags" } */
-  printf ("%+ d", i); /* { dg-warning "use of both|ignored" "use of space and + flags" } */
-  printf ("% d% i% f% F% e% E% g% G% a% A\n", i, i, d, d, d, d, d, d, d, d);
-  printf ("% o", u); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% u", u); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% x", u); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% X", u); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% c", i); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% s", s); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% p", p); /* { dg-warning "flag" "bad use of space flag" } */
-  printf ("% n", n); /* { dg-warning "flag" "bad use of space flag" } */
-  /* Uses of the # flag.  */
-  printf ("%#o%#x%#X%#e%#E%#f%#F%#g%#G%#a%#A", u, u, u, d, d, d, d,
-         d, d, d, d);
-  printf ("%#d", i); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#i", i); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#u", u); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#c", i); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#s", s); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#p", p); /* { dg-warning "flag" "bad use of # flag" } */
-  printf ("%#n", n); /* { dg-warning "flag" "bad use of # flag" } */
-  /* Uses of the 0 flag.  */
-  printf ("%08d%08i%08o%08u%08x%08X%08e%08E%08f%08F%08g%08G%08a%08A", i, i,
-         u, u, u, u, d, d, d, d, d, d, d, d);
-  printf ("%0c", i); /* { dg-warning "flag" "bad use of 0 flag" } */
-  printf ("%0s", s); /* { dg-warning "flag" "bad use of 0 flag" } */
-  printf ("%0p", p); /* { dg-warning "flag" "bad use of 0 flag" } */
-  printf ("%0n", n); /* { dg-warning "flag" "bad use of 0 flag" } */
-  /* 0 flag ignored with precision for certain types, not others.  */
-  printf ("%08.5d", i); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5i", i); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5o", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5u", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5x", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5X", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
-  printf ("%08.5f%08.5F%08.5e%08.5E%08.5g%08.5G%08.5a%08.5A",
-         d, d, d, d, d, d, d, d);
-  /* 0 flag ignored with - flag.  */
-  printf ("%-08d", i); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08i", i); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08o", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08u", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08x", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08X", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08e", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08E", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08f", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08F", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08g", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08G", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08a", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  printf ("%-08A", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
-  /* Various tests of bad argument types.  Mostly covered in c90-printf-1.c;
-     here just test for pointer target sign with %hhn.  (Probably allowed
-     by the standard, but a bad idea, so GCC should diagnose if what
-     is used is not signed char *.)
-  */
-  printf ("%hhn", s); /* { dg-warning "format" "%hhn plain char" } */
-  printf ("%hhn", us); /* { dg-warning "format" "%hhn unsigned char" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c99-printf-2.c b/gcc/testsuite/gcc.dg/c99-printf-2.c
deleted file mode 100644 (file)
index 26b9de9..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Test for printf formats.  Formats using extensions to the standard
-   should be rejected in strict pedantic mode.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
-
-typedef __SIZE_TYPE__ size_t;
-typedef __WCHAR_TYPE__ wchar_t;
-typedef __WINT_TYPE__ wint_t;
-
-extern int printf (const char *, ...);
-
-void
-foo (int i, long long ll, size_t z, wint_t lc, wchar_t *ls)
-{
-  /* The length modifiers q, Z and L as applied to integer formats are
-     extensions.
-  */
-  printf ("%qd", ll); /* { dg-warning "C" "%q length" } */
-  printf ("%Ld", ll); /* { dg-warning "C" "%L length" } */
-  printf ("%Zd", z); /* { dg-warning "C" "%Z length" } */
-  /* The conversion specifiers C and S are X/Open extensions; the
-     conversion specifier m is a GNU extension.
-  */
-  printf ("%m"); /* { dg-warning "C" "printf %m" } */
-  printf ("%C", lc); /* { dg-warning "C" "printf %C" } */
-  printf ("%S", ls); /* { dg-warning "C" "printf %S" } */
-  /* The flag character ', and the use of operand number $ formats, are
-     X/Open extensions.
-  */
-  printf ("%'d", i); /* { dg-warning "C" "printf ' flag" } */
-  printf ("%1$d", i); /* { dg-warning "C" "printf $ format" } */
-  /* The flag character I is a GNU extension.  */
-  printf ("%Id", i); /* { dg-warning "C" "printf I flag" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c99-printf-3.c b/gcc/testsuite/gcc.dg/c99-printf-3.c
deleted file mode 100644 (file)
index 26f76d7..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Test for printf formats.  Test that the C99 functions get their default
-   attributes in strict C99 mode, but the gettext functions do not.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
-
-/* This may not be correct in the particular case, but allows the
-   prototypes to be declared, and we don't try to link.
-*/
-typedef struct _FILE FILE;
-extern FILE *stdout;
-
-typedef __SIZE_TYPE__ size_t;
-typedef __builtin_va_list va_list;
-
-extern int fprintf (FILE *restrict, const char *restrict, ...);
-extern int printf (const char *restrict, ...);
-extern int sprintf (char *restrict, const char *restrict, ...);
-extern int vfprintf (FILE *restrict, const char *restrict, va_list);
-extern int vprintf (const char *restrict, va_list);
-extern int vsprintf (char *restrict, const char *restrict, va_list);
-extern int snprintf (char *restrict, size_t, const char *restrict, ...);
-extern int vsnprintf (char *restrict, size_t, const char *restrict, va_list);
-
-extern char *gettext (const char *);
-extern char *dgettext (const char *, const char *);
-extern char *dcgettext (const char *, const char *, int);
-
-void
-foo (int i, char *s, size_t n, va_list v0, va_list v1, va_list v2, va_list v3,
-     va_list v4, va_list v5, va_list v6, va_list v7)
-{
-  fprintf (stdout, "%d", i);
-  fprintf (stdout, "%ld", i); /* { dg-warning "format" "fprintf" } */
-  printf ("%d", i);
-  printf ("%ld", i); /* { dg-warning "format" "printf" } */
-  sprintf (s, "%d", i);
-  sprintf (s, "%ld", i); /* { dg-warning "format" "sprintf" } */
-  snprintf (s, n, "%d", i);
-  snprintf (s, n, "%ld", i); /* { dg-warning "format" "snprintf" } */
-  vfprintf (stdout, "%d", v0);
-  vfprintf (stdout, "%Y", v1); /* { dg-warning "format" "vfprintf" } */
-  vprintf ("%d", v0);
-  vprintf ("%Y", v1); /* { dg-warning "format" "vprintf" } */
-  vsprintf (s, "%d", v0);
-  vsprintf (s, "%Y", v1); /* { dg-warning "format" "vsprintf" } */
-  vsnprintf (s, n, "%d", v0);
-  vsnprintf (s, n, "%Y", v1); /* { dg-warning "format" "vsnprintf" } */
-  printf (gettext ("%d"), i);
-  printf (gettext ("%ld"), i);
-  printf (dgettext ("", "%d"), i);
-  printf (dgettext ("", "%ld"), i);
-  printf (dcgettext ("", "%d", 0), i);
-  printf (dcgettext ("", "%ld", 0), i);
-}
diff --git a/gcc/testsuite/gcc.dg/c99-scanf-1.c b/gcc/testsuite/gcc.dg/c99-scanf-1.c
deleted file mode 100644 (file)
index 369f02e..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/* Test for scanf formats.  Formats using C99 features, including cases
-   where C99 specifies some aspect of the format to be ignored or where
-   the behaviour is undefined.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
-
-typedef __WCHAR_TYPE__ wchar_t;
-typedef __SIZE_TYPE__ size_t;
-typedef __PTRDIFF_TYPE__ ptrdiff_t;
-
-/* Kludges to get types corresponding to size_t and ptrdiff_t.  */
-#define unsigned signed
-typedef __SIZE_TYPE__ signed_size_t;
-#undef unsigned
-#define signed /* Type might or might not have explicit 'signed'.  */
-typedef unsigned __PTRDIFF_TYPE__ unsigned_ptrdiff_t;
-#undef signed
-
-/* These next definitions are kludges.  When GCC has a <stdint.h> it
-   should be used.
-*/
-#include <limits.h>
-#if INT_MAX == LLONG_MAX
-typedef int intmax_t;
-#elif LONG_MAX == LLONG_MAX
-typedef long intmax_t;
-#else
-typedef long long intmax_t;
-#endif
-#if UINT_MAX == ULLONG_MAX
-typedef unsigned int uintmax_t;
-#elif ULONG_MAX == ULLONG_MAX
-typedef unsigned long uintmax_t;
-#else
-typedef unsigned long long uintmax_t;
-#endif
-
-extern int scanf (const char *, ...);
-
-void
-foo (int *ip, unsigned int *uip, short int *hp, unsigned short int *uhp,
-     signed char *hhp, unsigned char *uhhp, long int *lp,
-     unsigned long int *ulp, float *fp, double *dp, long double *ldp, char *s,
-     void **pp, int *n, long long *llp, unsigned long long *ullp, wchar_t *ls,
-     short int *hn, signed char *hhn, long int *ln, long long int *lln,
-     intmax_t *jp, uintmax_t *ujp, intmax_t *jn, size_t *zp,
-     signed_size_t *szp, signed_size_t *zn, ptrdiff_t *tp,
-     unsigned_ptrdiff_t *utp, ptrdiff_t *tn)
-{
-  /* See ISO/IEC 9899:1999 (E) subclause 7.19.6.2 (pages 281-288).
-     We do not repeat here most of the checks for correct C90 formats
-     or completely broken formats.
-  */
-  /* Valid, invalid and silly assignment-suppression
-     and width constructions.
-  */
-  scanf ("%*d%*i%*o%*u%*x%*X%*a%*A%*e%*E%*f%*F%*g%*G%*s%*[abc]%*c%*p");
-  scanf ("%*2d%*8s%*3c");
-  scanf ("%*n", n); /* { dg-warning "suppress" "suppression of %n" } */
-  scanf ("%*hd"); /* { dg-warning "together" "suppression with length" } */
-  scanf ("%2d%3i%4o%5u%6x%7X%8a%9A%10e%11E%12f%13F%14g%15G%16s%3[abc]%4c%5p",
-        ip, ip, uip, uip, uip, uip, fp, fp, fp, fp, fp, fp, fp, fp,
-        s, s, s, pp);
-  scanf ("%0d", ip); /* { dg-warning "width" "warning for zero width" } */
-  scanf ("%3n", n); /* { dg-warning "width" "width with %n" } */
-  /* Valid and invalid %h, %hh, %l, %ll, %j, %z, %t, %L constructions.  */
-  scanf ("%hd%hi%ho%hu%hx%hX%hn", hp, hp, uhp, uhp, uhp, uhp, hn);
-  scanf ("%ha", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hA", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%he", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hE", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hf", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hF", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hg", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hG", fp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hs", s); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%h[ac]", s); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hc", s); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hp", pp); /* { dg-warning "length" "bad use of %h" } */
-  scanf ("%hhd%hhi%hho%hhu%hhx%hhX%hhn", hhp, hhp, uhhp, uhhp, uhhp, uhhp,
-        hhn);
-  scanf ("%hha", fp); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%hhA", fp); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%hhe", fp); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%hhE", fp); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%hhf", fp); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%hhF", fp); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%hhg", fp); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%hhG", fp); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%hhs", s); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%hh[ac]", s); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%hhc", s); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%hhp", pp); /* { dg-warning "length" "bad use of %hh" } */
-  scanf ("%ld%li%lo%lu%lx%lX%ln", lp, lp, ulp, ulp, ulp, ulp, ln);
-  scanf ("%la%lA%le%lE%lf%lF%lg%lG", dp, dp, dp, dp, dp, dp, dp, dp);
-  scanf ("%lp", pp); /* { dg-warning "length" "bad use of %l" } */
-  scanf ("%ls", ls);
-  scanf ("%l[ac]", ls);
-  scanf ("%lc", ls);
-  scanf ("%lld%lli%llo%llu%llx%llX%lln", llp, llp, ullp, ullp, ullp, ullp,
-        lln);
-  scanf ("%lla", fp); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%llA", fp); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%lle", fp); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%llE", fp); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%llf", fp); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%llF", fp); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%llg", fp); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%llG", fp); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%lls", s); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%ll[ac]", s); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%llc", s); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%llp", pp); /* { dg-warning "length" "bad use of %ll" } */
-  scanf ("%jd%ji%jo%ju%jx%jX%jn", jp, jp, ujp, ujp, ujp, ujp, jn); /* { dg-bogus "length" "bogus %j warning" { target *-*-* } } */
-  scanf ("%ja", fp); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%jA", fp); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%je", fp); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%jE", fp); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%jf", fp); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%jF", fp); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%jg", fp); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%jG", fp); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%js", s); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%j[ac]", s); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%jc", s); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%jp", pp); /* { dg-warning "length" "bad use of %j" } */
-  scanf ("%zd%zi%zo%zu%zx%zX%zn", szp, szp, zp, zp, zp, zp, zn);
-  scanf ("%za", fp); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%zA", fp); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%ze", fp); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%zE", fp); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%zf", fp); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%zF", fp); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%zg", fp); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%zG", fp); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%zs", s); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%z[ac]", s); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%zc", s); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%zp", pp); /* { dg-warning "length" "bad use of %z" } */
-  scanf ("%td%ti%to%tu%tx%tX%tn", tp, tp, utp, utp, utp, utp, tn);
-  scanf ("%ta", fp); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%tA", fp); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%te", fp); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%tE", fp); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%tf", fp); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%tF", fp); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%tg", fp); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%tG", fp); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%ts", s); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%t[ac]", s); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%tc", s); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%tp", pp); /* { dg-warning "length" "bad use of %t" } */
-  scanf ("%La%LA%Le%LE%Lf%LF%Lg%LG", ldp, ldp, ldp, ldp, ldp, ldp, ldp, ldp);
-  scanf ("%Ld", llp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%Li", llp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%Lo", ullp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%Lu", ullp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%Lx", ullp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%LX", ullp); /* { dg-warning "does not support" "bad use of %L" } */
-  scanf ("%Ls", s); /* { dg-warning "length" "bad use of %L" } */
-  scanf ("%L[ac]", s); /* { dg-warning "length" "bad use of %L" } */
-  scanf ("%Lc", s); /* { dg-warning "length" "bad use of %L" } */
-  scanf ("%Lp", pp); /* { dg-warning "length" "bad use of %L" } */
-  scanf ("%Ln", n); /* { dg-warning "length" "bad use of %L" } */
-  /* Valid uses of each bare conversion.  */
-  scanf ("%d%i%o%u%x%X%a%A%e%E%f%F%g%G%s%[abc]%c%p%n%%", ip, ip, uip, uip, uip,
-         uip, fp, fp, fp, fp, fp, fp, fp, fp, s, s, s, pp, n);
-  /* Assert that %as is not treated as an extension in C99 mode.  */
-  scanf ("%as", fp);
-  scanf ("%a[", fp);
-  /* Tests for bad argument types: pointer target sign with %hh.  */
-  scanf ("%hhd", uhhp); /* { dg-warning "format" "%hhd sign" } */
-  scanf ("%hhu", hhp); /* { dg-warning "format" "%hhu sign" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c99-scanf-2.c b/gcc/testsuite/gcc.dg/c99-scanf-2.c
deleted file mode 100644 (file)
index a740a60..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Test for scanf formats.  Formats using extensions to the standard
-   should be rejected in strict pedantic mode.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
-
-typedef __WCHAR_TYPE__ wchar_t;
-
-extern int scanf (const char *, ...);
-
-void
-foo (int *ip, long long int *llp, wchar_t *ls)
-{
-  /* The length modifiers q and L as applied to integer formats are
-     extensions.
-  */
-  scanf ("%qd", llp); /* { dg-warning "C" "%q length" } */
-  scanf ("%Ld", llp); /* { dg-warning "C" "%L length" } */
-  /* The conversion specifiers C and S are X/Open extensions.  */
-  scanf ("%C", ls); /* { dg-warning "C" "scanf %C" } */
-  scanf ("%S", ls); /* { dg-warning "C" "scanf %S" } */
-  /* The use of operand number $ formats is an X/Open extension.  */
-  scanf ("%1$d", ip); /* { dg-warning "C" "scanf $ format" } */
-  /* glibc also supports flags ' and I on scanf formats as an extension.  */
-  scanf ("%'d", ip); /* { dg-warning "C" "scanf ' flag" } */
-  scanf ("%Id", ip); /* { dg-warning "C" "scanf I flag" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c99-scanf-3.c b/gcc/testsuite/gcc.dg/c99-scanf-3.c
deleted file mode 100644 (file)
index df30c05..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Test for scanf formats.  Test that the C99 functions get their default
-   attributes in strict C99 mode, but the gettext functions do not.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
-
-/* This may not be correct in the particular case, but allows the
-   prototypes to be declared, and we don't try to link.
-*/
-typedef struct _FILE FILE;
-extern FILE *stdin;
-
-typedef __builtin_va_list va_list;
-
-extern int fscanf (FILE *restrict, const char *restrict, ...);
-extern int scanf (const char *restrict, ...);
-extern int sscanf (const char *restrict, const char *restrict, ...);
-extern int vfscanf (FILE *restrict, const char *restrict, va_list);
-extern int vscanf (const char *restrict, va_list);
-extern int vsscanf (const char *restrict, const char *restrict, va_list);
-
-extern char *gettext (const char *);
-extern char *dgettext (const char *, const char *);
-extern char *dcgettext (const char *, const char *, int);
-
-void
-foo (int *ip, char *s, va_list v0, va_list v1, va_list v2, va_list v3,
-     va_list v4, va_list v5)
-{
-  fscanf (stdin, "%d", ip);
-  fscanf (stdin, "%ld", ip); /* { dg-warning "format" "fscanf" } */
-  scanf ("%d", ip);
-  scanf ("%ld", ip); /* { dg-warning "format" "scanf" } */
-  sscanf (s, "%d", ip);
-  sscanf (s, "%ld", ip); /* { dg-warning "format" "sscanf" } */
-  vfscanf (stdin, "%d", v0);
-  vfscanf (stdin, "%Y", v1); /* { dg-warning "format" "vfscanf" } */
-  vscanf ("%d", v2);
-  vscanf ("%Y", v3); /* { dg-warning "format" "vscanf" } */
-  vsscanf (s, "%d", v4);
-  vsscanf (s, "%Y", v5); /* { dg-warning "format" "vsscanf" } */
-  scanf (gettext ("%d"), ip);
-  scanf (gettext ("%ld"), ip);
-  scanf (dgettext ("", "%d"), ip);
-  scanf (dgettext ("", "%ld"), ip);
-  scanf (dcgettext ("", "%d", 0), ip);
-  scanf (dcgettext ("", "%ld", 0), ip);
-}
diff --git a/gcc/testsuite/gcc.dg/c99-strftime-1.c b/gcc/testsuite/gcc.dg/c99-strftime-1.c
deleted file mode 100644 (file)
index 187fc7c..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Test for strftime formats.  Formats using C99 features.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
-
-typedef __SIZE_TYPE__ size_t;
-
-struct tm;
-
-extern size_t strftime (char *, size_t, const char *, const struct tm *);
-
-void
-foo (char *s, size_t m, const struct tm *tp)
-{
-  /* See ISO/IEC 9899:1990 (E) subclause 7.12.3.5 (pages 174-175).  */
-  /* Formats which are Y2K-compliant (no 2-digit years).  */
-  strftime (s, m, "%a%A%b%B%C%d%e%F%G%h%H%I%j%m%M%p%R%S%t%T%u%U%V%w%W%X%Y%z%Z%%", tp);
-  strftime (s, m, "%EC%EX%EY%Od%Oe%OH%OI%Om%OM%OS%Ou%OU%OV%Ow%OW", tp);
-  /* Formats with 2-digit years.  */
-  strftime (s, m, "%D", tp); /* { dg-warning "only last 2" "2-digit year" } */
-  strftime (s, m, "%g", tp); /* { dg-warning "only last 2" "2-digit year" } */
-  strftime (s, m, "%y", tp); /* { dg-warning "only last 2" "2-digit year" } */
-  strftime (s, m, "%Oy", tp); /* { dg-warning "only last 2" "2-digit year" } */
-  /* Formats with 2-digit years in some locales.  */
-  strftime (s, m, "%c", tp); /* { dg-warning "some locales" "2-digit year" } */
-  strftime (s, m, "%Ec", tp); /* { dg-warning "some locales" "2-digit year" } */
-  strftime (s, m, "%x", tp); /* { dg-warning "some locales" "2-digit year" } */
-  strftime (s, m, "%Ex", tp); /* { dg-warning "some locales" "2-digit year" } */
-  /* %Ey is explicitly an era offset not a 2-digit year; but in some
-     locales the E modifier may be ignored.
-  */
-  strftime (s, m, "%Ey", tp); /* { dg-warning "some locales" "2-digit year" } */
-  /* Bad uses of %E and %O.  */
-  strftime (s, m, "%EEY", tp); /* { dg-warning "multiple|repeated" "multiple %E/%O" } */
-  strftime (s, m, "%EOy", tp); /* { dg-warning "multiple|together" "multiple %E/%O" } */
-  strftime (s, m, "%OEy", tp); /* { dg-warning "multiple|together" "multiple %E/%O" } */
-  strftime (s, m, "%OOV", tp); /* { dg-warning "multiple|repeated" "multiple %E/%O" } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 35 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 36 } */
-  strftime (s, m, "%Ea", tp); /* { dg-warning "flag|modifier" "bad %Ea" } */
-  strftime (s, m, "%EA", tp); /* { dg-warning "flag|modifier" "bad %EA" } */
-  strftime (s, m, "%Eb", tp); /* { dg-warning "flag|modifier" "bad %Eb" } */
-  strftime (s, m, "%EB", tp); /* { dg-warning "flag|modifier" "bad %EB" } */
-  strftime (s, m, "%Ed", tp); /* { dg-warning "flag|modifier" "bad %Ed" } */
-  strftime (s, m, "%ED", tp); /* { dg-warning "flag|modifier" "bad %ED" } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 45 } */
-  strftime (s, m, "%Ee", tp); /* { dg-warning "flag|modifier" "bad %Ee" } */
-  strftime (s, m, "%EF", tp); /* { dg-warning "flag|modifier" "bad %EF" } */
-  strftime (s, m, "%Eg", tp); /* { dg-warning "flag|modifier" "bad %Eg" } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 49 } */
-  strftime (s, m, "%EG", tp); /* { dg-warning "flag|modifier" "bad %EG" } */
-  strftime (s, m, "%Eh", tp); /* { dg-warning "flag|modifier" "bad %Eh" } */
-  strftime (s, m, "%EH", tp); /* { dg-warning "flag|modifier" "bad %EH" } */
-  strftime (s, m, "%EI", tp); /* { dg-warning "flag|modifier" "bad %EI" } */
-  strftime (s, m, "%Ej", tp); /* { dg-warning "flag|modifier" "bad %Ej" } */
-  strftime (s, m, "%Em", tp); /* { dg-warning "flag|modifier" "bad %Em" } */
-  strftime (s, m, "%EM", tp); /* { dg-warning "flag|modifier" "bad %EM" } */
-  strftime (s, m, "%En", tp); /* { dg-warning "flag|modifier" "bad %En" } */
-  strftime (s, m, "%Ep", tp); /* { dg-warning "flag|modifier" "bad %Ep" } */
-  strftime (s, m, "%Er", tp); /* { dg-warning "flag|modifier" "bad %Er" } */
-  strftime (s, m, "%ER", tp); /* { dg-warning "flag|modifier" "bad %ER" } */
-  strftime (s, m, "%ES", tp); /* { dg-warning "flag|modifier" "bad %ES" } */
-  strftime (s, m, "%Et", tp); /* { dg-warning "flag|modifier" "bad %Et" } */
-  strftime (s, m, "%ET", tp); /* { dg-warning "flag|modifier" "bad %ET" } */
-  strftime (s, m, "%Eu", tp); /* { dg-warning "flag|modifier" "bad %Eu" } */
-  strftime (s, m, "%EU", tp); /* { dg-warning "flag|modifier" "bad %EU" } */
-  strftime (s, m, "%EV", tp); /* { dg-warning "flag|modifier" "bad %EV" } */
-  strftime (s, m, "%Ew", tp); /* { dg-warning "flag|modifier" "bad %Ew" } */
-  strftime (s, m, "%EW", tp); /* { dg-warning "flag|modifier" "bad %EW" } */
-  strftime (s, m, "%Ez", tp); /* { dg-warning "flag|modifier" "bad %Ez" } */
-  strftime (s, m, "%EZ", tp); /* { dg-warning "flag|modifier" "bad %EZ" } */
-  strftime (s, m, "%E%", tp); /* { dg-warning "flag|modifier" "bad %E%" } */
-  strftime (s, m, "%Oa", tp); /* { dg-warning "flag|modifier" "bad %Oa" } */
-  strftime (s, m, "%OA", tp); /* { dg-warning "flag|modifier" "bad %OA" } */
-  strftime (s, m, "%Ob", tp); /* { dg-warning "flag|modifier" "bad %Ob" } */
-  strftime (s, m, "%OB", tp); /* { dg-warning "flag|modifier" "bad %OB" } */
-  strftime (s, m, "%Oc", tp); /* { dg-warning "flag|modifier" "bad %Oc" } */
-  /* { dg-warning "in some locales" "2-digit year" { target *-*-* } 77 } */
-  strftime (s, m, "%OC", tp); /* { dg-warning "flag|modifier|C" "bad %OC" } */
-  strftime (s, m, "%OD", tp); /* { dg-warning "flag|modifier" "bad %OD" } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 80 } */
-  strftime (s, m, "%OF", tp); /* { dg-warning "flag|modifier" "bad %OF" } */
-  strftime (s, m, "%Og", tp); /* { dg-warning "flag|modifier|C" "bad %Og" } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 83 } */
-  strftime (s, m, "%OG", tp); /* { dg-warning "flag|modifier|C" "bad %OG" } */
-  strftime (s, m, "%Oh", tp); /* { dg-warning "flag|modifier" "bad %Oh" } */
-  strftime (s, m, "%Oj", tp); /* { dg-warning "flag|modifier|C" "bad %Oj" } */
-  strftime (s, m, "%On", tp); /* { dg-warning "flag|modifier" "bad %On" } */
-  strftime (s, m, "%Op", tp); /* { dg-warning "flag|modifier" "bad %Op" } */
-  strftime (s, m, "%Or", tp); /* { dg-warning "flag|modifier" "bad %Or" } */
-  strftime (s, m, "%OR", tp); /* { dg-warning "flag|modifier" "bad %OR" } */
-  strftime (s, m, "%Ot", tp); /* { dg-warning "flag|modifier" "bad %Ot" } */
-  strftime (s, m, "%OT", tp); /* { dg-warning "flag|modifier" "bad %OT" } */
-  strftime (s, m, "%Ox", tp); /* { dg-warning "flag|modifier" "bad %Ox" } */
-  /* { dg-warning "in some locales" "2-digit year" { target *-*-* } 94 } */
-  strftime (s, m, "%OX", tp); /* { dg-warning "flag|modifier" "bad %OX" } */
-  strftime (s, m, "%OY", tp); /* { dg-warning "flag|modifier|C" "bad %OY" } */
-  strftime (s, m, "%Oz", tp); /* { dg-warning "flag|modifier|C" "bad %Oz" } */
-  strftime (s, m, "%OZ", tp); /* { dg-warning "flag|modifier" "bad %OZ" } */
-  strftime (s, m, "%O%", tp); /* { dg-warning "flag|modifier" "bad %O%" } */
-}
diff --git a/gcc/testsuite/gcc.dg/c99-strftime-2.c b/gcc/testsuite/gcc.dg/c99-strftime-2.c
deleted file mode 100644 (file)
index 45d8ef4..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Test for strftime formats.  Rejection of extensions in pedantic mode.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
-
-typedef __SIZE_TYPE__ size_t;
-
-struct tm;
-
-extern size_t strftime (char *, size_t, const char *, const struct tm *);
-
-void
-foo (char *s, size_t m, const struct tm *tp)
-{
-  /* %P is a lowercase version of %p.  */
-  strftime (s, m, "%P", tp); /* { dg-warning "C" "strftime %P" } */
-  /* %k is %H but padded with a space rather than 0 if necessary.  */
-  strftime (s, m, "%k", tp); /* { dg-warning "C" "strftime %k" } */
-  /* %l is %I but padded with a space rather than 0 if necessary.  */
-  strftime (s, m, "%l", tp); /* { dg-warning "C" "strftime %l" } */
-  /* %s is the number of seconds since the Epoch.  */
-  strftime (s, m, "%s", tp); /* { dg-warning "C" "strftime %s" } */
-  /* Extensions using %O already tested in c99-strftime-1.c.  */
-  /* Width and flags are GNU extensions for strftime.  */
-  strftime (s, m, "%20Y", tp); /* { dg-warning "C" "strftime width" } */
-  strftime (s, m, "%^A", tp); /* { dg-warning "C" "strftime flags" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-array-1.c b/gcc/testsuite/gcc.dg/format-array-1.c
deleted file mode 100644 (file)
index 8d632a7..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Test for format checking of constant arrays.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat=2" } */
-
-extern int printf (const char *, ...);
-
-const char a1[] = "foo";
-const char a2[] = "foo%d";
-const char b[3] = "foo";
-static const char c1[] = "foo";
-static const char c2[] = "foo%d";
-char d[] = "foo";
-volatile const char e[] = "foo";
-
-void
-foo (int i, long l)
-{
-  const char p1[] = "bar";
-  const char p2[] = "bar%d";
-  static const char q1[] = "bar";
-  static const char q2[] = "bar%d";
-  printf (a1);
-  printf (a2, i);
-  printf (a2, l); /* { dg-warning "format" "wrong type with array" } */
-  printf (b); /* { dg-warning "unterminated" "unterminated array" } */
-  printf (c1);
-  printf (c2, i);
-  printf (c2, l); /* { dg-warning "format" "wrong type with array" } */
-  printf (p1);
-  printf (p2, i);
-  printf (p2, l); /* { dg-warning "format" "wrong type with array" } */
-  printf (q1);
-  printf (q2, i);
-  printf (q2, l); /* { dg-warning "format" "wrong type with array" } */
-  /* Volatile or non-constant arrays must not be checked.  */
-  printf (d); /* { dg-warning "not a string literal" "non-const" } */
-  printf ((const char *)e); /* { dg-warning "not a string literal" "volatile" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-attr-1.c b/gcc/testsuite/gcc.dg/format-attr-1.c
deleted file mode 100644 (file)
index e6ebaf2..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Test for strftime format attributes: can't have first_arg_num != 0.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat" } */
-
-extern void foo0 (const char *) __attribute__((__format__(__strftime__, 1, 0)));
-extern void foo1 (const char *, ...) __attribute__((__format__(__strftime__, 1, 2))); /* { dg-error "cannot format" "strftime first_arg_num != 0" } */
diff --git a/gcc/testsuite/gcc.dg/format-branch-1.c b/gcc/testsuite/gcc.dg/format-branch-1.c
deleted file mode 100644 (file)
index 6ff4131..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Test for format checking of conditional expressions.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat" } */
-
-#define NULL ((void *)0)
-
-extern int printf (const char *, ...);
-
-void
-foo (long l, int nfoo)
-{
-  printf ((nfoo > 1) ? "%d foos" : "%d foo", nfoo);
-  printf ((l > 1) ? "%d foos" : "%d foo", l); /* { dg-warning "int format" "wrong type in conditional expr" } */
-  printf ((l > 1) ? "%ld foos" : "%d foo", l); /* { dg-warning "int format" "wrong type in conditional expr" } */
-  printf ((l > 1) ? "%d foos" : "%ld foo", l); /* { dg-warning "int format" "wrong type in conditional expr" } */
-  /* Should allow one case to have extra arguments.  */
-  printf ((nfoo > 1) ? "%d foos" : "1 foo", nfoo);
-  printf ((nfoo > 1) ? "many foos" : "1 foo", nfoo); /* { dg-warning "too many" "too many args in all branches" } */
-  printf ((nfoo > 1) ? "%d foos" : "", nfoo);
-  printf ((nfoo > 1) ? "%d foos" : ((nfoo > 0) ? "1 foo" : "no foos"), nfoo);
-  printf ((nfoo > 1) ? "%d foos" : ((nfoo > 0) ? "%d foo" : "%d foos"), nfoo);
-  printf ((nfoo > 1) ? "%d foos" : ((nfoo > 0) ? "%d foo" : "%ld foos"), nfoo); /* { dg-warning "long int format" "wrong type" } */
-  printf ((nfoo > 1) ? "%ld foos" : ((nfoo > 0) ? "%d foo" : "%d foos"), nfoo); /* { dg-warning "long int format" "wrong type" } */
-  printf ((nfoo > 1) ? "%d foos" : ((nfoo > 0) ? "%ld foo" : "%d foos"), nfoo); /* { dg-warning "long int format" "wrong type" } */
-  /* Extra arguments to NULL should be complained about.  */
-  printf (NULL, "foo"); /* { dg-warning "too many" "NULL extra args" } */
-  /* { dg-warning "null" "null format arg" { target *-*-* } 27 } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-diag-1.c b/gcc/testsuite/gcc.dg/format-diag-1.c
deleted file mode 100644 (file)
index 33364d7..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Test for format diagnostics.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat" } */
-
-extern int printf (const char *, ...);
-
-void
-foo (double d)
-{
-  /* This should get a message referring to `hh', not to `H'.  */
-  printf ("%hhf", d); /* { dg-warning "hh" "%hhf warning" } */
-  /* This should get a message referring to `ll', not to `q'.  */
-  printf ("%llf", d); /* { dg-warning "ll" "%llf warning" } */
-  /* This should get a message referring to `size_t format', not to
-     `unsigned int format' or similar.  */
-  printf ("%zu", d); /* { dg-warning "size_t format" "size_t format warning" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-errmk-1.c b/gcc/testsuite/gcc.dg/format-errmk-1.c
deleted file mode 100644 (file)
index bf05f4e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Test for format checking not giving tree checking errors.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-Wformat" } */
-
-extern int printf (const char *, ...);
-
-void
-foo (int t)
-{
-  printf ("%*d", u, t); /* { dg-error "undeclared|function" "u undeclared error" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-ext-1.c b/gcc/testsuite/gcc.dg/format-ext-1.c
deleted file mode 100644 (file)
index 238a478..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Test for format extensions beyond the C standard and X/Open standard.
-   Test for printf formats.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat" } */
-
-/* %q formats want a "quad"; GCC considers this to be a long long.  */
-typedef long long int quad_t;
-typedef unsigned long long int u_quad_t;
-
-typedef __WCHAR_TYPE__ wchar_t;
-typedef __WINT_TYPE__ wint_t;
-typedef __SIZE_TYPE__ size_t;
-
-extern int printf (const char *, ...);
-
-void
-foo (quad_t q, u_quad_t uq, quad_t *qn, size_t z, size_t *zn, long long int ll,
-     unsigned long long int ull, int i, unsigned int u, double d,
-     char *s, void *p, wchar_t *ls, wint_t lc, int *n, long int l)
-{
-  /* As an extension, GCC allows the BSD length "q" for integer formats.
-     This is largely obsoleted in C99 by %j, %ll and PRId64.
-  */
-  printf ("%qd%qi%qo%qu%qx%qX%qn", q, q, uq, uq, uq, uq, qn);
-  printf ("%qf", d); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qF", d); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qe", d); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qE", d); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qg", d); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qG", d); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qa", d); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qA", d); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qc", i); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qs", s); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qp", p); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qC", lc); /* { dg-warning "length" "bad use of %q" } */
-  printf ("%qS", ls); /* { dg-warning "length" "bad use of %q" } */
-  /* With a bad length GCC wants some argument, any argument,
-     to devour with the format conversion, as a synchronisation heuristic.
-     This may get improved later.
-  */
-  printf ("%qm", i); /* { dg-warning "length" "bad use of %q" } */
-  /* As an extension, GCC allows the length "Z" as a synonym for "z".
-     This was an extension predating C99 which should now be considered
-     deprecated; use the standard "z" instead.
-  */
-  printf ("%Zd%Zi%Zo%Zu%Zx%ZX", z, z, z, z, z, z);
-  printf ("%Zn", zn);
-  printf ("%Zf", d); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%ZF", d); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%Ze", d); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%ZE", d); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%Zg", d); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%ZG", d); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%Za", d); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%ZA", d); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%Zc", i); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%Zs", s); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%Zp", p); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%ZC", lc); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%ZS", ls); /* { dg-warning "length" "bad use of %Z" } */
-  printf ("%Zm", i); /* { dg-warning "length" "bad use of %Z" } */
-  /* As an extension, GCC allows the length "L" on integer formats
-     (but not %n) as a synonym for "ll".
-     This should be considered deprecated.
-  */
-  printf ("%Ld%Li%Lo%Lu%Lx%LX", ll, ll, ull, ull, ull, ull);
-  /* As an extension, derived from syslog, GCC allows the conversion
-     specifier "m" for formatting strerror(errno).  This may be used
-     with width, precision and the "-" flag, the same as %s.
-  */
-  printf ("%m%3m%.4m%5.6m");
-  printf ("%*m", i);
-  printf ("%.*m", i);
-  printf ("%*.*m", i, i);
-  printf ("%3.*m", i);
-  printf ("%*.4m", i);
-  printf ("%-m");
-  printf ("%+m"); /* { dg-warning "flag" "bad %+m" } */
-  printf ("% m"); /* { dg-warning "flag" "bad % m" } */
-  printf ("%#m"); /* { dg-warning "flag" "bad %#m" } */
-  printf ("%0m"); /* { dg-warning "flag" "bad %0m" } */
-  printf ("%'m"); /* { dg-warning "flag" "bad %'m" } */
-  printf ("%hm", i); /* { dg-warning "length" "bad %hm" } */
-  printf ("%hhm", i); /* { dg-warning "length" "bad %hhm" } */
-  printf ("%lm", i); /* { dg-warning "length" "bad %lm" } */
-  printf ("%llm", i); /* { dg-warning "length" "bad %llm" } */
-  printf ("%jm", i); /* { dg-warning "length" "bad %jm" } */
-  printf ("%zm", i); /* { dg-warning "length" "bad %zm" } */
-  printf ("%tm", i); /* { dg-warning "length" "bad %tm" } */
-  printf ("%Lm", i); /* { dg-warning "length" "bad %Lm" } */
-  printf ("%qm", i); /* { dg-warning "length" "bad %qm" } */
-  printf ("%Zm", i); /* { dg-warning "length" "bad %Zm" } */
-  /* It should be OK to mix %m formats with $ operand number formats.  */
-  printf ("%2$ld%m%1$d", i, l);
-  /* Likewise, %m formats with width and precision should not have an
-     operand number for the %m itself.
-  */
-  printf ("%*2$.*1$m", i, i);
-  printf ("%1$*2$.*1$m", i, i); /* { dg-warning "no argument" "printf %1\$m" } */
-  /* As an extension, glibc includes the "I" flag for decimal integer
-     formats, to output using the locale's digits (e.g. in Arabic).
-     In GCC, we require this to be in the standard place for flags, though
-     glibc allows it also after width or precision.
-  */
-  printf ("%Id%Ii%Iu", i, i, u);
-  printf ("%Io", u); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%Ix", u); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%IX", u); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%In", n); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%If", d); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%IF", d); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%Ie", d); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%IE", d); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%Ig", d); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%IG", d); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%Ia", d); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%IA", d); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%Ic", i); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%Is", s); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%Ip", p); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%IC", lc); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%IS", ls); /* { dg-warning "flag" "bad use of I flag" } */
-  printf ("%Im"); /* { dg-warning "flag" "bad use of I flag" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-ext-2.c b/gcc/testsuite/gcc.dg/format-ext-2.c
deleted file mode 100644 (file)
index 68c1b03..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Test for format extensions beyond the C standard and X/Open standard.
-   Test for scanf formats.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat" } */
-
-/* %q formats want a "quad"; GCC considers this to be a long long.  */
-typedef long long int quad_t;
-typedef unsigned long long int u_quad_t;
-
-typedef __WCHAR_TYPE__ wchar_t;
-
-extern int scanf (const char *, ...);
-
-void
-foo (quad_t *qp, u_quad_t *uqp, quad_t *qn, long long int *llp,
-     unsigned long long int *ullp, float *fp, char *s, void **pp, wchar_t *ls,
-     int *ip, unsigned int *up)
-{
-  /* As an extension, GCC allows the BSD length "q" for integer formats.
-     This is largely obsoleted in C99 by %j, %ll and SCNd64.
-  */
-  scanf ("%qd%qi%qo%qu%qx%qX%qn", qp, qp, uqp, uqp, uqp, uqp, qn);
-  scanf ("%qf", fp); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qF", fp); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qe", fp); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qE", fp); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qg", fp); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qG", fp); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qa", fp); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qA", fp); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qs", s); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%q[abc]", s); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qc", s); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qp", pp); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qC", ls); /* { dg-warning "length" "bad use of %q" } */
-  scanf ("%qS", ls); /* { dg-warning "length" "bad use of %q" } */
-  /* As an extension, GCC allows the length "L" on integer formats
-     (but not %n) as a synonym for "ll".
-     This should be considered deprecated.
-  */
-  scanf ("%Ld%Li%Lo%Lu%Lx%LX", llp, llp, ullp, ullp, ullp, ullp);
-  /* glibc also supports flags ' and I on scanf formats.  The ' flag applies
-     to all formats scanning decimal values; the I flag only to decimal integer
-     formats.
-  */
-  scanf ("%'d%'i%'u%'a%'A%'e%'E%'f%'F%'g%'G", ip, ip, up, fp, fp, fp, fp,
-        fp, fp, fp, fp);
-  scanf ("%'o", up); /* { dg-warning "flag" "bad use of ' flag" } */
-  scanf ("%'x", up); /* { dg-warning "flag" "bad use of ' flag" } */
-  scanf ("%'X", up); /* { dg-warning "flag" "bad use of ' flag" } */
-  scanf ("%'n", ip); /* { dg-warning "flag" "bad use of ' flag" } */
-  scanf ("%'s", s); /* { dg-warning "flag" "bad use of ' flag" } */
-  scanf ("%'[abc]", s); /* { dg-warning "flag" "bad use of ' flag" } */
-  scanf ("%'c", s); /* { dg-warning "flag" "bad use of ' flag" } */
-  scanf ("%'p", pp); /* { dg-warning "flag" "bad use of ' flag" } */
-  scanf ("%'C", ls); /* { dg-warning "flag" "bad use of ' flag" } */
-  scanf ("%'S", ls); /* { dg-warning "flag" "bad use of ' flag" } */
-  scanf ("%Id%Ii%Iu", ip, ip, up);
-  scanf ("%Ia", fp); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%IA", fp); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%Ie", fp); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%IE", fp); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%If", fp); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%IF", fp); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%Ig", fp); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%IG", fp); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%Io", up); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%Ix", up); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%IX", up); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%In", ip); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%Is", s); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%I[abc]", s); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%Ic", s); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%Ip", pp); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%IC", ls); /* { dg-warning "flag" "bad use of I flag" } */
-  scanf ("%IS", ls); /* { dg-warning "flag" "bad use of I flag" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-ext-3.c b/gcc/testsuite/gcc.dg/format-ext-3.c
deleted file mode 100644 (file)
index ea9f2e0..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/* Test for format extensions beyond the C standard and X/Open standard.
-   Test for strftime formats.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat" } */
-
-typedef __SIZE_TYPE__ size_t;
-
-struct tm;
-
-extern size_t strftime (char *, size_t, const char *, const struct tm *);
-
-void
-foo (char *s, size_t m, const struct tm *tp)
-{
-  /* GCC accepts the "-", "_" and "0" flags to control padding on numeric
-     formats.  It also accepts width on these formats.
-  */
-  /* Basic tests of parts on their own.  */
-  strftime (s, m, "%5C%-C%_C%0C", tp);
-  /* Correct usages.  */
-  strftime (s, m, "%-5C%_5C%05C%-5d%_5d%05d%-5e%_5e%05e%-5G%_5G%05G", tp);
-  strftime (s, m, "%-5H%_5H%05H%-5I%_5I%05I%-5j%_5j%05j%-5m%_5m%05m", tp);
-  strftime (s, m, "%-5M%_5M%05M%-5S%_5S%05S%-5u%_5u%05u%-5U%_5U%05U", tp);
-  strftime (s, m, "%-5V%_5V%05V%-5w%_5w%05w%-5W%_5W%05W%-5Y%_5Y%05Y", tp);
-  /* Correct usages with GNU extension conversion characters.  */
-  strftime (s, m, "%-5k%_5k%05k%-5l%_5l%05l%-20s%_20s%020s", tp);
-  /* Correct usages with Y2K problems.  */
-  strftime (s, m, "%-5g%_5g%05g%-5y%_5y%05y", tp); /* { dg-warning "only last 2" "2-digit year" } */
-  /* Incorrect usages.  */
-  strftime (s, m, "%5a", tp); /* { dg-warning "width" "bad %a" } */
-  strftime (s, m, "%-a", tp); /* { dg-warning "flag" "bad %a" } */
-  strftime (s, m, "%_a", tp); /* { dg-warning "flag" "bad %a" } */
-  strftime (s, m, "%0a", tp); /* { dg-warning "flag" "bad %a" } */
-  strftime (s, m, "%5A", tp); /* { dg-warning "width" "bad %A" } */
-  strftime (s, m, "%-A", tp); /* { dg-warning "flag" "bad %A" } */
-  strftime (s, m, "%_A", tp); /* { dg-warning "flag" "bad %A" } */
-  strftime (s, m, "%0A", tp); /* { dg-warning "flag" "bad %A" } */
-  strftime (s, m, "%5b", tp); /* { dg-warning "width" "bad %b" } */
-  strftime (s, m, "%-b", tp); /* { dg-warning "flag" "bad %b" } */
-  strftime (s, m, "%_b", tp); /* { dg-warning "flag" "bad %b" } */
-  strftime (s, m, "%0b", tp); /* { dg-warning "flag" "bad %b" } */
-  strftime (s, m, "%5B", tp); /* { dg-warning "width" "bad %B" } */
-  strftime (s, m, "%-B", tp); /* { dg-warning "flag" "bad %B" } */
-  strftime (s, m, "%_B", tp); /* { dg-warning "flag" "bad %B" } */
-  strftime (s, m, "%0B", tp); /* { dg-warning "flag" "bad %B" } */
-  strftime (s, m, "%5F", tp); /* { dg-warning "width" "bad %F" } */
-  strftime (s, m, "%-F", tp); /* { dg-warning "flag" "bad %F" } */
-  strftime (s, m, "%_F", tp); /* { dg-warning "flag" "bad %F" } */
-  strftime (s, m, "%0F", tp); /* { dg-warning "flag" "bad %F" } */
-  strftime (s, m, "%5h", tp); /* { dg-warning "width" "bad %h" } */
-  strftime (s, m, "%-h", tp); /* { dg-warning "flag" "bad %h" } */
-  strftime (s, m, "%_h", tp); /* { dg-warning "flag" "bad %h" } */
-  strftime (s, m, "%0h", tp); /* { dg-warning "flag" "bad %h" } */
-  strftime (s, m, "%5n", tp); /* { dg-warning "width" "bad %n" } */
-  strftime (s, m, "%-n", tp); /* { dg-warning "flag" "bad %n" } */
-  strftime (s, m, "%_n", tp); /* { dg-warning "flag" "bad %n" } */
-  strftime (s, m, "%0n", tp); /* { dg-warning "flag" "bad %n" } */
-  strftime (s, m, "%5p", tp); /* { dg-warning "width" "bad %p" } */
-  strftime (s, m, "%-p", tp); /* { dg-warning "flag" "bad %p" } */
-  strftime (s, m, "%_p", tp); /* { dg-warning "flag" "bad %p" } */
-  strftime (s, m, "%0p", tp); /* { dg-warning "flag" "bad %p" } */
-  strftime (s, m, "%5r", tp); /* { dg-warning "width" "bad %r" } */
-  strftime (s, m, "%-r", tp); /* { dg-warning "flag" "bad %r" } */
-  strftime (s, m, "%_r", tp); /* { dg-warning "flag" "bad %r" } */
-  strftime (s, m, "%0r", tp); /* { dg-warning "flag" "bad %r" } */
-  strftime (s, m, "%5R", tp); /* { dg-warning "width" "bad %R" } */
-  strftime (s, m, "%-R", tp); /* { dg-warning "flag" "bad %R" } */
-  strftime (s, m, "%_R", tp); /* { dg-warning "flag" "bad %R" } */
-  strftime (s, m, "%0R", tp); /* { dg-warning "flag" "bad %R" } */
-  strftime (s, m, "%5t", tp); /* { dg-warning "width" "bad %t" } */
-  strftime (s, m, "%-t", tp); /* { dg-warning "flag" "bad %t" } */
-  strftime (s, m, "%_t", tp); /* { dg-warning "flag" "bad %t" } */
-  strftime (s, m, "%0t", tp); /* { dg-warning "flag" "bad %t" } */
-  strftime (s, m, "%5T", tp); /* { dg-warning "width" "bad %T" } */
-  strftime (s, m, "%-T", tp); /* { dg-warning "flag" "bad %T" } */
-  strftime (s, m, "%_T", tp); /* { dg-warning "flag" "bad %T" } */
-  strftime (s, m, "%0T", tp); /* { dg-warning "flag" "bad %T" } */
-  strftime (s, m, "%5X", tp); /* { dg-warning "width" "bad %X" } */
-  strftime (s, m, "%-X", tp); /* { dg-warning "flag" "bad %X" } */
-  strftime (s, m, "%_X", tp); /* { dg-warning "flag" "bad %X" } */
-  strftime (s, m, "%0X", tp); /* { dg-warning "flag" "bad %X" } */
-  strftime (s, m, "%5z", tp); /* { dg-warning "width" "bad %z" } */
-  strftime (s, m, "%-z", tp); /* { dg-warning "flag" "bad %z" } */
-  strftime (s, m, "%_z", tp); /* { dg-warning "flag" "bad %z" } */
-  strftime (s, m, "%0z", tp); /* { dg-warning "flag" "bad %z" } */
-  strftime (s, m, "%5Z", tp); /* { dg-warning "width" "bad %Z" } */
-  strftime (s, m, "%-Z", tp); /* { dg-warning "flag" "bad %Z" } */
-  strftime (s, m, "%_Z", tp); /* { dg-warning "flag" "bad %Z" } */
-  strftime (s, m, "%0Z", tp); /* { dg-warning "flag" "bad %Z" } */
-  /* Incorrect usages with Y2K problems.  */
-  strftime (s, m, "%5c", tp); /* { dg-warning "width" "bad %c" } */
-  strftime (s, m, "%-c", tp); /* { dg-warning "flag" "bad %c" } */
-  strftime (s, m, "%_c", tp); /* { dg-warning "flag" "bad %c" } */
-  strftime (s, m, "%0c", tp); /* { dg-warning "flag" "bad %c" } */
-  strftime (s, m, "%5D", tp); /* { dg-warning "width" "bad %D" } */
-  strftime (s, m, "%-D", tp); /* { dg-warning "flag" "bad %D" } */
-  strftime (s, m, "%_D", tp); /* { dg-warning "flag" "bad %D" } */
-  strftime (s, m, "%0D", tp); /* { dg-warning "flag" "bad %D" } */
-  strftime (s, m, "%5x", tp); /* { dg-warning "width" "bad %x" } */
-  strftime (s, m, "%-x", tp); /* { dg-warning "flag" "bad %x" } */
-  strftime (s, m, "%_x", tp); /* { dg-warning "flag" "bad %x" } */
-  strftime (s, m, "%0x", tp); /* { dg-warning "flag" "bad %x" } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 93 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 94 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 95 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 96 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 97 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 98 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 99 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 100 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 101 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 102 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 103 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 104 } */
-  /* Incorrect usages with GNU extension conversion characters.  */
-  strftime (s, m, "%5P", tp); /* { dg-warning "width" "bad %P" } */
-  strftime (s, m, "%-P", tp); /* { dg-warning "flag" "bad %P" } */
-  strftime (s, m, "%_P", tp); /* { dg-warning "flag" "bad %P" } */
-  strftime (s, m, "%0P", tp); /* { dg-warning "flag" "bad %P" } */
-  /* The "^" and "#" flags control the case of the output.
-     ^ (uppercase) makes sense on aAbBhZ; # (change case) makes sense
-     on the same and on p.
-  */
-  strftime (s, m, "%^a%#a%^A%#A%^b%#b%^B%#B%^h%#h%^Z%#Z%#p", tp);
-  /* Bad usages.  */
-  strftime (s, m, "%^C", tp); /* { dg-warning "flag" "bad %C" } */
-  strftime (s, m, "%#C", tp); /* { dg-warning "flag" "bad %C" } */
-  strftime (s, m, "%^d", tp); /* { dg-warning "flag" "bad %d" } */
-  strftime (s, m, "%#d", tp); /* { dg-warning "flag" "bad %d" } */
-  strftime (s, m, "%^e", tp); /* { dg-warning "flag" "bad %e" } */
-  strftime (s, m, "%#e", tp); /* { dg-warning "flag" "bad %e" } */
-  strftime (s, m, "%^F", tp); /* { dg-warning "flag" "bad %F" } */
-  strftime (s, m, "%#F", tp); /* { dg-warning "flag" "bad %F" } */
-  strftime (s, m, "%^G", tp); /* { dg-warning "flag" "bad %G" } */
-  strftime (s, m, "%#G", tp); /* { dg-warning "flag" "bad %G" } */
-  strftime (s, m, "%^H", tp); /* { dg-warning "flag" "bad %H" } */
-  strftime (s, m, "%#H", tp); /* { dg-warning "flag" "bad %H" } */
-  strftime (s, m, "%^I", tp); /* { dg-warning "flag" "bad %I" } */
-  strftime (s, m, "%#I", tp); /* { dg-warning "flag" "bad %I" } */
-  strftime (s, m, "%^j", tp); /* { dg-warning "flag" "bad %j" } */
-  strftime (s, m, "%#j", tp); /* { dg-warning "flag" "bad %j" } */
-  strftime (s, m, "%^m", tp); /* { dg-warning "flag" "bad %m" } */
-  strftime (s, m, "%#m", tp); /* { dg-warning "flag" "bad %m" } */
-  strftime (s, m, "%^M", tp); /* { dg-warning "flag" "bad %M" } */
-  strftime (s, m, "%#M", tp); /* { dg-warning "flag" "bad %M" } */
-  strftime (s, m, "%^n", tp); /* { dg-warning "flag" "bad %n" } */
-  strftime (s, m, "%#n", tp); /* { dg-warning "flag" "bad %n" } */
-  strftime (s, m, "%^p", tp); /* { dg-warning "flag" "bad %p" } */
-  strftime (s, m, "%^r", tp); /* { dg-warning "flag" "bad %r" } */
-  strftime (s, m, "%#r", tp); /* { dg-warning "flag" "bad %r" } */
-  strftime (s, m, "%^R", tp); /* { dg-warning "flag" "bad %R" } */
-  strftime (s, m, "%#R", tp); /* { dg-warning "flag" "bad %R" } */
-  strftime (s, m, "%^S", tp); /* { dg-warning "flag" "bad %S" } */
-  strftime (s, m, "%#S", tp); /* { dg-warning "flag" "bad %S" } */
-  strftime (s, m, "%^t", tp); /* { dg-warning "flag" "bad %t" } */
-  strftime (s, m, "%#t", tp); /* { dg-warning "flag" "bad %t" } */
-  strftime (s, m, "%^T", tp); /* { dg-warning "flag" "bad %T" } */
-  strftime (s, m, "%#T", tp); /* { dg-warning "flag" "bad %T" } */
-  strftime (s, m, "%^u", tp); /* { dg-warning "flag" "bad %u" } */
-  strftime (s, m, "%#u", tp); /* { dg-warning "flag" "bad %u" } */
-  strftime (s, m, "%^U", tp); /* { dg-warning "flag" "bad %U" } */
-  strftime (s, m, "%#U", tp); /* { dg-warning "flag" "bad %U" } */
-  strftime (s, m, "%^V", tp); /* { dg-warning "flag" "bad %V" } */
-  strftime (s, m, "%#V", tp); /* { dg-warning "flag" "bad %V" } */
-  strftime (s, m, "%^w", tp); /* { dg-warning "flag" "bad %w" } */
-  strftime (s, m, "%#w", tp); /* { dg-warning "flag" "bad %w" } */
-  strftime (s, m, "%^W", tp); /* { dg-warning "flag" "bad %W" } */
-  strftime (s, m, "%#W", tp); /* { dg-warning "flag" "bad %W" } */
-  strftime (s, m, "%^X", tp); /* { dg-warning "flag" "bad %X" } */
-  strftime (s, m, "%#X", tp); /* { dg-warning "flag" "bad %X" } */
-  strftime (s, m, "%^Y", tp); /* { dg-warning "flag" "bad %Y" } */
-  strftime (s, m, "%#Y", tp); /* { dg-warning "flag" "bad %Y" } */
-  strftime (s, m, "%^z", tp); /* { dg-warning "flag" "bad %z" } */
-  strftime (s, m, "%#z", tp); /* { dg-warning "flag" "bad %z" } */
-  strftime (s, m, "%^P", tp); /* { dg-warning "flag" "bad %P" } */
-  strftime (s, m, "%#P", tp); /* { dg-warning "flag" "bad %P" } */
-  strftime (s, m, "%^k", tp); /* { dg-warning "flag" "bad %k" } */
-  strftime (s, m, "%#k", tp); /* { dg-warning "flag" "bad %k" } */
-  strftime (s, m, "%^l", tp); /* { dg-warning "flag" "bad %l" } */
-  strftime (s, m, "%#l", tp); /* { dg-warning "flag" "bad %l" } */
-  strftime (s, m, "%^s", tp); /* { dg-warning "flag" "bad %s" } */
-  strftime (s, m, "%#s", tp); /* { dg-warning "flag" "bad %s" } */
-  /* Bad usages with Y2K problems.  */
-  strftime (s, m, "%^c", tp); /* { dg-warning "flag" "bad %c" } */
-  strftime (s, m, "%#c", tp); /* { dg-warning "flag" "bad %c" } */
-  strftime (s, m, "%^D", tp); /* { dg-warning "flag" "bad %D" } */
-  strftime (s, m, "%#D", tp); /* { dg-warning "flag" "bad %D" } */
-  strftime (s, m, "%^g", tp); /* { dg-warning "flag" "bad %g" } */
-  strftime (s, m, "%#g", tp); /* { dg-warning "flag" "bad %g" } */
-  strftime (s, m, "%^x", tp); /* { dg-warning "flag" "bad %x" } */
-  strftime (s, m, "%#x", tp); /* { dg-warning "flag" "bad %x" } */
-  strftime (s, m, "%^y", tp); /* { dg-warning "flag" "bad %y" } */
-  strftime (s, m, "%#y", tp); /* { dg-warning "flag" "bad %y" } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 186 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 187 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 188 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 189 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 190 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 191 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 192 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 193 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 194 } */
-  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 195 } */
-  /* GCC also accepts the glibc format extensions %P, %k, %l, %s.  */
-  strftime (s, m, "%P%k%l%s", tp);
-  /* GCC also accepts the glibc extension of the "O" modifier on some
-     more formats.  The cases where it is rejected altogether are
-     covered in c99-strftime-1.c, except for the extension %P.
-  */
-  strftime (s, m, "%OC%Og%OG%Oj%OY%Oz%Ok%Ol%Os", tp); /* { dg-warning "only last 2" "2-digit year" } */
-  strftime (s, m, "%OP", tp); /* { dg-warning "flag|modifier" "bad %OP" } */
-  /* The "-", "_" and "0" flags are mutually exclusive.  */
-  strftime (s, m, "%-_5C", tp); /* { dg-warning "flag" "bad %-_" } */
-  strftime (s, m, "%-05C", tp); /* { dg-warning "flag" "bad %-0" } */
-  strftime (s, m, "%_05C", tp); /* { dg-warning "flag" "bad %_0" } */
-  /* The "#" and "^" flags are mutually exclusive.  */
-  strftime (s, m, "%^#a", tp); /* { dg-warning "flag" "bad %^#" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-ext-4.c b/gcc/testsuite/gcc.dg/format-ext-4.c
deleted file mode 100644 (file)
index c0cf740..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Test for scanf formats.  %a extensions.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu89 -Wformat" } */
-
-typedef __WCHAR_TYPE__ wchar_t;
-
-extern int scanf (const char *, ...);
-
-void
-foo (char **sp, wchar_t **lsp)
-{
-  /* %a formats for allocation, only recognised in C90 mode, are a
-     GNU extension.  Followed by other characters, %a is not treated
-     specially.
-  */
-  scanf ("%as", sp);
-  scanf ("%aS", lsp);
-  scanf ("%a[bcd]", sp);
-}
diff --git a/gcc/testsuite/gcc.dg/format-ext-5.c b/gcc/testsuite/gcc.dg/format-ext-5.c
deleted file mode 100644 (file)
index e3cce44..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Test for gettext default attributes.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat" } */
-
-extern int printf (const char *, ...);
-
-extern char *gettext (const char *);
-extern char *dgettext (const char *, const char *);
-extern char *dcgettext (const char *, const char *, int);
-
-void
-foo (int i, long l)
-{
-  printf (gettext ("%d"), i);
-  printf (gettext ("%ld"), i); /* { dg-warning "format" "gettext" } */
-  printf (dgettext ("", "%d"), i);
-  printf (dgettext ("", "%ld"), i); /* { dg-warning "format" "dgettext" } */
-  printf (dcgettext ("", "%d", 0), i);
-  printf (dcgettext ("", "%ld", 0), i); /* { dg-warning "format" "dcgettext" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-miss-1.c b/gcc/testsuite/gcc.dg/format-miss-1.c
deleted file mode 100644 (file)
index a5d467a..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Test for warnings for missing format attributes.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat -Wmissing-format-attribute" } */
-
-#include <stdarg.h>
-
-extern int vprintf (const char *restrict, va_list);
-extern int vscanf (const char *restrict, va_list);
-
-void
-foo (const char *fmt, ...)
-{
-  va_list ap;
-  va_start (ap, fmt);
-  vprintf (fmt, ap); /* { dg-warning "candidate" "printf attribute warning" } */
-  va_end (ap);
-}
-
-void
-bar (const char *fmt, ...)
-{
-  va_list ap;
-  va_start (ap, fmt);
-  vscanf (fmt, ap); /* { dg-warning "candidate" "scanf attribute warning" } */
-  va_end (ap);
-}
-
-__attribute__((__format__(__printf__, 1, 2))) void
-foo2 (const char *fmt, ...)
-{
-  va_list ap;
-  va_start (ap, fmt);
-  vprintf (fmt, ap);
-  va_end (ap);
-}
-
-void
-vfoo (const char *fmt, va_list arg)
-{
-  vprintf (fmt, arg); /* { dg-warning "candidate" "printf attribute warning 2" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-miss-2.c b/gcc/testsuite/gcc.dg/format-miss-2.c
deleted file mode 100644 (file)
index b7c5501..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Test for warnings for missing format attributes.  Don't warn if no
-   relevant parameters for a format attribute; see c/1017.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat -Wmissing-format-attribute" } */
-
-#include <stdarg.h>
-
-extern int vprintf (const char *restrict, va_list);
-
-void
-foo (int i, ...)
-{
-  va_list ap;
-  va_start (ap, i);
-  vprintf ("Foo %s bar %s", ap); /* { dg-bogus "candidate" "bogus printf attribute warning" } */
-  va_end (ap);
-}
diff --git a/gcc/testsuite/gcc.dg/format-no-exargs-1.c b/gcc/testsuite/gcc.dg/format-no-exargs-1.c
deleted file mode 100644 (file)
index bbf5a8a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Test for warnings for extra format arguments being disabled by
-   -Wno-format-extra-args.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat -Wno-format-extra-args" } */
-
-extern int printf (const char *, ...);
-
-void
-foo (int i)
-{
-  printf ("foo", i);
-  printf ("%1$d", i, i);
-}
diff --git a/gcc/testsuite/gcc.dg/format-no-y2k-1.c b/gcc/testsuite/gcc.dg/format-no-y2k-1.c
deleted file mode 100644 (file)
index e41d26d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Test for warnings for Y2K problems being disabled by -Wno-format-y2k.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat -Wno-format-y2k" } */
-
-typedef __SIZE_TYPE__ size_t;
-
-struct tm;
-
-extern size_t strftime (char *, size_t, const char *, const struct tm *);
-
-void
-foo (char *s, size_t m, const struct tm *tp)
-{
-  strftime (s, m, "%y%c%x", tp);
-}
diff --git a/gcc/testsuite/gcc.dg/format-nonlit-1.c b/gcc/testsuite/gcc.dg/format-nonlit-1.c
deleted file mode 100644 (file)
index e40bf08..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Test for warnings for non-string-literal formats.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat -Wformat-nonliteral" } */
-
-extern int printf (const char *, ...);
-
-void
-foo (char *s, __SIZE_TYPE__ i)
-{
-  printf ((const char *)i, i); /* { dg-warning "argument types" "non-literal" } */
-  printf (s, i); /* { dg-warning "argument types" "non-literal" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-nonlit-2.c b/gcc/testsuite/gcc.dg/format-nonlit-2.c
deleted file mode 100644 (file)
index 9c3eee8..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Test for warnings for non-string-literal formats.  Test with -Wformat=2.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat=2" } */
-
-extern int printf (const char *, ...);
-
-void
-foo (char *s, __SIZE_TYPE__ i)
-{
-  printf ((const char *)i, i); /* { dg-warning "argument types" "non-literal" } */
-  printf (s, i); /* { dg-warning "argument types" "non-literal" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-nonlit-3.c b/gcc/testsuite/gcc.dg/format-nonlit-3.c
deleted file mode 100644 (file)
index 4423151..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Test for warnings for non-string-literal formats.  Test for strftime formats.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat -Wformat-nonliteral" } */
-
-typedef __SIZE_TYPE__ size_t;
-
-struct tm;
-
-extern size_t strftime (char *, size_t, const char *, const struct tm *);
-
-void
-foo (char *s, size_t m, const struct tm *tp, char *fmt)
-{
-  strftime (s, m, fmt, tp); /* { dg-warning "format string" "non-literal" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-sec-1.c b/gcc/testsuite/gcc.dg/format-sec-1.c
deleted file mode 100644 (file)
index 5ca4905..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Test for security warning when non-literal format has no arguments.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat -Wformat-security" } */
-
-extern int printf (const char *, ...);
-
-void
-foo (char *s)
-{
-  printf (s); /* { dg-warning "no format arguments" "security warning" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-strfmon-1.c b/gcc/testsuite/gcc.dg/format-strfmon-1.c
deleted file mode 100644 (file)
index 40d44c1..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Test for strfmon format checking.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat" } */
-
-typedef __SIZE_TYPE__ size_t;
-
-/* Kludge to get something that may be ssize_t.  */
-#define unsigned signed
-typedef __SIZE_TYPE__ ssize_t;
-#undef unsigned
-
-#define NULL ((void *)0)
-
-extern ssize_t strfmon (char *restrict, size_t, const char *restrict, ...);
-
-void
-foo (char *s, size_t m, double d, long double ld)
-{
-  /* Examples of valid formats from Austin Group draft 5.  */
-  strfmon (s, m, "%n", d);
-  strfmon (s, m, "%11n", d);
-  strfmon (s, m, "%#5n", d);
-  strfmon (s, m, "%=*#5n", d);
-  strfmon (s, m, "%=0#5n", d);
-  strfmon (s, m, "%^#5n", d);
-  strfmon (s, m, "%^#5.0n", d);
-  strfmon (s, m, "%^#5.4n", d);
-  strfmon (s, m, "%(#5n", d);
-  strfmon (s, m, "%(!#5n", d);
-  /* Some more valid formats, including the GNU L length extension.  */
-  strfmon (s, m, "abc%-11ndef%==i%%", d, d);
-  strfmon (s, m, "%%abc%-11ndef%==Li%=%i", d, ld, d);
-  strfmon (s, m, "%Li", ld);
-  strfmon (s, m, "%11Li", ld);
-  strfmon (s, m, "%#5Li", ld);
-  strfmon (s, m, "%=*#5Li", ld);
-  strfmon (s, m, "%=0#5Li", ld);
-  strfmon (s, m, "%^#5Li", ld);
-  strfmon (s, m, "%^#5.0Li", ld);
-  strfmon (s, m, "%^#5.4Li", ld);
-  strfmon (s, m, "%(#5Li", ld);
-  strfmon (s, m, "%(!#5Li", ld);
-  /* Formats with the wrong types used.  */
-  strfmon (s, m, "%Ln", d); /* { dg-warning "format" "wrong type" } */
-  strfmon (s, m, "%n", ld); /* { dg-warning "format" "wrong type" } */
-  /* The + and ( flags cannot be used together.  */
-  strfmon (s, m, "%+(i", d); /* { dg-warning "flag" "+ and ( flags" } */
-  strfmon (s, m, "%(+i", d); /* { dg-warning "flag" "+ and ( flags" } */
-  /* Although empty precision is OK for printf, it isn't here.  */
-  strfmon (s, m, "%#.5n", d); /* { dg-warning "empty" "empty left precision" } */
-  strfmon (s, m, "%#5.n", d); /* { dg-warning "empty" "empty right precision" } */
-  /* However, zero is a valid value for width and precisions.  */
-  strfmon (s, m, "%0#0.0n", d);
-  /* Test bogus %% constructions.  */
-  strfmon (s, m, "%^%"); /* { dg-warning "format" "bogus %%" } */
-  strfmon (s, m, "%!%\n"); /* { dg-warning "format" "bogus %%" } */
-  strfmon (s, m, "%5%\n"); /* { dg-warning "format" "bogus %%" } */
-  strfmon (s, m, "%.5%\n"); /* { dg-warning "format" "bogus %%" } */
-  strfmon (s, m, "%#5%\n"); /* { dg-warning "format" "bogus %%" } */
-  /* Miscellaneous bogus formats.  */
-  strfmon (s, m, "%n%n", d); /* { dg-warning "arguments" "too few args" } */
-  strfmon (s, m, ""); /* { dg-warning "zero-length" "empty" } */
-  strfmon (s, m, NULL); /* { dg-warning "null" "null format string" } */
-  strfmon (s, m, "%"); /* { dg-warning "trailing" "tailing %" } */
-  strfmon (s, m, "%n\0", d); /* { dg-warning "embedded" "embedded NUL" } */
-  strfmon (s, m, "%^^n", d); /* { dg-warning "repeated" "repeated flag" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-va-1.c b/gcc/testsuite/gcc.dg/format-va-1.c
deleted file mode 100644 (file)
index 9538e2b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Test for strange warning in format checking.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-Wformat" } */
-
-extern int printf (const char *, ...);
-
-void
-foo (void *p)
-{
-  printf ("%d", p); /* { dg-bogus "va_list" "wrong type in format warning" } */
-  /* { dg-warning "format" "format error" { target *-*-* } 11 } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-warnll-1.c b/gcc/testsuite/gcc.dg/format-warnll-1.c
deleted file mode 100644 (file)
index 71a749b..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Test for printf formats.  C99 "long long" formats should be accepted with
-   -Wno-long-long.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=iso9899:1990 -pedantic -Wformat -Wno-long-long" } */
-
-extern int printf (const char *, ...);
-extern int scanf (const char *, ...);
-
-void
-foo (long long ll, unsigned long long ull, long long *lln,
-     long long *llp, unsigned long long *ullp)
-{
-  /* Test for accepting standard "long long" formats.  */
-  printf ("%lld%lli%llo%llu%llx%llX%lln", ll, ll, ull, ull, ull, ull, lln);
-  scanf ("%lld%lli%llo%llu%llx%llX%lln", llp, llp,
-        ullp, ullp, ullp, ullp, lln);
-  /* Use of "q" and "L" should still be warned about.  */
-  printf ("%qd", ll); /* { dg-warning "C" "printf %qd" } */
-  printf ("%qi", ll); /* { dg-warning "C" "printf %qi" } */
-  printf ("%qo", ull); /* { dg-warning "C" "printf %qo" } */
-  printf ("%qu", ull); /* { dg-warning "C" "printf %qu" } */
-  printf ("%qx", ull); /* { dg-warning "C" "printf %qx" } */
-  printf ("%qX", ull); /* { dg-warning "C" "printf %qX" } */
-  printf ("%qn", lln); /* { dg-warning "C" "printf %qn" } */
-  printf ("%Ld", ll); /* { dg-warning "C" "printf %Ld" } */
-  printf ("%Li", ll); /* { dg-warning "C" "printf %Li" } */
-  printf ("%Lo", ull); /* { dg-warning "C" "printf %oL" } */
-  printf ("%Lu", ull); /* { dg-warning "C" "printf %Lu" } */
-  printf ("%Lx", ull); /* { dg-warning "C" "printf %Lx" } */
-  printf ("%LX", ull); /* { dg-warning "C" "printf %LX" } */
-  scanf ("%qd", llp); /* { dg-warning "C" "scanf %qd" } */
-  scanf ("%qi", llp); /* { dg-warning "C" "scanf %qi" } */
-  scanf ("%qo", ullp); /* { dg-warning "C" "scanf %qo" } */
-  scanf ("%qu", ullp); /* { dg-warning "C" "scanf %qu" } */
-  scanf ("%qx", ullp); /* { dg-warning "C" "scanf %qx" } */
-  scanf ("%qX", ullp); /* { dg-warning "C" "scanf %qX" } */
-  scanf ("%qn", lln); /* { dg-warning "C" "scanf %qn" } */
-  scanf ("%Ld", llp); /* { dg-warning "C" "scanf %Ld" } */
-  scanf ("%Li", llp); /* { dg-warning "C" "scanf %Li" } */
-  scanf ("%Lo", ullp); /* { dg-warning "C" "scanf %oL" } */
-  scanf ("%Lu", ullp); /* { dg-warning "C" "scanf %Lu" } */
-  scanf ("%Lx", ullp); /* { dg-warning "C" "scanf %Lx" } */
-  scanf ("%LX", ullp); /* { dg-warning "C" "scanf %LX" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format-xopen-1.c b/gcc/testsuite/gcc.dg/format-xopen-1.c
deleted file mode 100644 (file)
index 99d571b..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/* Test for X/Open format extensions, as found in the
-   Single Unix Specification and in Austin Group draft 4, subject to some
-   Aardvark problem reports approved as changes.
-*/
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-std=gnu99 -Wformat" } */
-
-typedef __WCHAR_TYPE__ wchar_t;
-typedef __WINT_TYPE__ wint_t;
-typedef __builtin_va_list va_list;
-
-extern int printf (const char *, ...);
-extern int vprintf (const char *, va_list);
-extern int scanf (const char *, ...);
-
-void
-foo (int i, unsigned int u, wint_t lc, wchar_t *ls, int *ip, double d,
-     char *s, void *p, int *n, long int l, int i2, float *fp, long int *lp,
-     va_list va)
-{
-  /* The conversion specifiers C and S, for both printf and scanf,
-     are X/Open extensions.
-  */
-  printf ("%C", lc);
-  printf ("%3C", lc);
-  printf ("%.3C", lc); /* { dg-warning "precision" "precision with %C" } */
-  printf ("%hC", lc); /* { dg-warning "length" "bad %hC" } */
-  printf ("%hhC", lc); /* { dg-warning "length" "bad %hhC" } */
-  printf ("%lC", lc); /* { dg-warning "length" "bad %lC" } */
-  printf ("%llC", lc); /* { dg-warning "length" "bad %llC" } */
-  printf ("%jC", lc); /* { dg-warning "length" "bad %jC" } */
-  printf ("%zC", lc); /* { dg-warning "length" "bad %zC" } */
-  printf ("%tC", lc); /* { dg-warning "length" "bad %tC" } */
-  printf ("%LC", lc); /* { dg-warning "length" "bad %LC" } */
-  printf ("%-C", lc);
-  printf ("%+C", lc); /* { dg-warning "flag" "bad %+C" } */
-  printf ("% C", lc); /* { dg-warning "flag" "bad % C" } */
-  printf ("%#C", lc); /* { dg-warning "flag" "bad %#C" } */
-  printf ("%0C", lc); /* { dg-warning "flag" "bad %0C" } */
-  printf ("%'C", lc); /* { dg-warning "flag" "bad %'C" } */
-  printf ("%S", ls);
-  printf ("%3S", ls);
-  printf ("%.3S", ls);
-  printf ("%hS", ls); /* { dg-warning "length" "bad %hS" } */
-  printf ("%hhS", ls); /* { dg-warning "length" "bad %hhS" } */
-  printf ("%lS", ls); /* { dg-warning "length" "bad %lS" } */
-  printf ("%llS", ls); /* { dg-warning "length" "bad %llS" } */
-  printf ("%jS", ls); /* { dg-warning "length" "bad %jS" } */
-  printf ("%zS", ls); /* { dg-warning "length" "bad %zS" } */
-  printf ("%tS", ls); /* { dg-warning "length" "bad %tS" } */
-  printf ("%LS", ls); /* { dg-warning "length" "bad %LS" } */
-  printf ("%-S", ls);
-  printf ("%+S", ls); /* { dg-warning "flag" "bad %+S" } */
-  printf ("% S", ls); /* { dg-warning "flag" "bad % S" } */
-  printf ("%#S", ls); /* { dg-warning "flag" "bad %#S" } */
-  printf ("%0S", ls); /* { dg-warning "flag" "bad %0S" } */
-  printf ("%'S", ls); /* { dg-warning "flag" "bad %'S" } */
-  scanf ("%C", ls);
-  scanf ("%S", ls);
-  scanf ("%*C%*S");
-  scanf ("%2C%3S", ls, ls);
-  scanf ("%hC", ls); /* { dg-warning "length" "bad %hC" } */
-  scanf ("%hhC", ls); /* { dg-warning "length" "bad %hhC" } */
-  scanf ("%lC", ls); /* { dg-warning "length" "bad %lC" } */
-  scanf ("%llC", ls); /* { dg-warning "length" "bad %llC" } */
-  scanf ("%jC", ls); /* { dg-warning "length" "bad %jC" } */
-  scanf ("%zC", ls); /* { dg-warning "length" "bad %zC" } */
-  scanf ("%tC", ls); /* { dg-warning "length" "bad %tC" } */
-  scanf ("%LC", ls); /* { dg-warning "length" "bad %LC" } */
-  scanf ("%hS", ls); /* { dg-warning "length" "bad %hS" } */
-  scanf ("%hhS", ls); /* { dg-warning "length" "bad %hhS" } */
-  scanf ("%lS", ls); /* { dg-warning "length" "bad %lS" } */
-  scanf ("%llS", ls); /* { dg-warning "length" "bad %llS" } */
-  scanf ("%jS", ls); /* { dg-warning "length" "bad %jS" } */
-  scanf ("%zS", ls); /* { dg-warning "length" "bad %zS" } */
-  scanf ("%tS", ls); /* { dg-warning "length" "bad %tS" } */
-  scanf ("%LS", ls); /* { dg-warning "length" "bad %LS" } */
-  /* In C99 mode (even with extensions), %aS is a floating point
-     format followed by an S.
-  */
-  scanf ("%aS", fp);
-  /* The printf flag character ' is an X/Open extension.  */
-  printf ("%'d%'i%'u%'f%'F%'g%'G", i, i, u, d, d, d, d);
-  printf ("%'o", u); /* { dg-warning "flag" "bad use of ' flag" } */
-  printf ("%'x", u); /* { dg-warning "flag" "bad use of ' flag" } */
-  printf ("%'X", u); /* { dg-warning "flag" "bad use of ' flag" } */
-  printf ("%'e", d); /* { dg-warning "flag" "bad use of ' flag" } */
-  printf ("%'E", d); /* { dg-warning "flag" "bad use of ' flag" } */
-  printf ("%'a", d); /* { dg-warning "flag" "bad use of ' flag" } */
-  printf ("%'A", d); /* { dg-warning "flag" "bad use of ' flag" } */
-  printf ("%'c", i); /* { dg-warning "flag" "bad use of ' flag" } */
-  printf ("%'s", s); /* { dg-warning "flag" "bad use of ' flag" } */
-  printf ("%'p", p); /* { dg-warning "flag" "bad use of ' flag" } */
-  printf ("%'n", n); /* { dg-warning "flag" "bad use of ' flag" } */
-  /* The use of operand number $ formats is an X/Open extension.  */
-  /* Banning gaps in the arguments used with scanf was covered in Aardvark
-     report XSHd4 ERN 164, which was rejected, but implementation without
-     such a ban still isn't possible within ISO C.
-  */
-  scanf ("%1$d", ip);
-  printf ("%1$d", i);
-  printf ("%1$d", l); /* { dg-warning "arg 2" "mismatched args with $ format" } */
-  printf ("%3$*2$.*1$ld", i2, i, l);
-  printf ("%4$ld%7$ld%5$d%6$d%3$d%1$d%2$d", i, i, i, l, i, i, l);
-  scanf ("%4$ld%7$ld%5$d%6$d%3$d%1$d%2$d", ip, ip, ip, lp, ip, ip, lp);
-  printf ("%1$d%d", i, i); /* { dg-warning "missing" "mixing $ and non-$ formats" } */
-  printf ("%%%1$d%%%2$d", i, i);
-  printf ("%d%2$d", i); /* { dg-warning "type character" "mixing $ and non-$ formats" } */
-  printf ("%1$*d", i, i); /* { dg-warning "missing" "mixing $ and non-$ formats" } */
-  printf ("%*1$d", i); /* { dg-warning "missing" "mixing $ and non-$ formats" } */
-  scanf ("%1$d%d", ip, ip); /* { dg-warning "missing" "mixing $ and non-$ formats" } */
-  scanf ("%*f%%%1$d%%%2$d", ip, ip);
-  printf ("%2$d", i); /* { dg-warning "operand" "$ number too large" } */
-  printf ("%0$d", i); /* { dg-warning "operand" "$ number too small" } */
-  printf ("%3$d%1$d", i, i, i); /* { dg-warning "before used" "unused $ operand" } */
-  printf ("%2$d%1$d", i, i, i); /* { dg-warning "unused" "unused $ operand" } */
-  vprintf ("%3$d%1$d", va); /* { dg-warning "before used" "unused $ operand" } */
-  scanf ("%2$*d%1$d", ip, ip); /* { dg-warning "operand" "operand number with suppression" } */
-  printf ("%1$d%1$d", i);
-  scanf ("%1$d%1$d", ip); /* { dg-warning "more than once" "multiple use of scanf argument" } */
-}
diff --git a/gcc/testsuite/gcc.dg/format/array-1.c b/gcc/testsuite/gcc.dg/format/array-1.c
new file mode 100644 (file)
index 0000000..8d632a7
--- /dev/null
@@ -0,0 +1,39 @@
+/* Test for format checking of constant arrays.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat=2" } */
+
+extern int printf (const char *, ...);
+
+const char a1[] = "foo";
+const char a2[] = "foo%d";
+const char b[3] = "foo";
+static const char c1[] = "foo";
+static const char c2[] = "foo%d";
+char d[] = "foo";
+volatile const char e[] = "foo";
+
+void
+foo (int i, long l)
+{
+  const char p1[] = "bar";
+  const char p2[] = "bar%d";
+  static const char q1[] = "bar";
+  static const char q2[] = "bar%d";
+  printf (a1);
+  printf (a2, i);
+  printf (a2, l); /* { dg-warning "format" "wrong type with array" } */
+  printf (b); /* { dg-warning "unterminated" "unterminated array" } */
+  printf (c1);
+  printf (c2, i);
+  printf (c2, l); /* { dg-warning "format" "wrong type with array" } */
+  printf (p1);
+  printf (p2, i);
+  printf (p2, l); /* { dg-warning "format" "wrong type with array" } */
+  printf (q1);
+  printf (q2, i);
+  printf (q2, l); /* { dg-warning "format" "wrong type with array" } */
+  /* Volatile or non-constant arrays must not be checked.  */
+  printf (d); /* { dg-warning "not a string literal" "non-const" } */
+  printf ((const char *)e); /* { dg-warning "not a string literal" "volatile" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/attr-1.c b/gcc/testsuite/gcc.dg/format/attr-1.c
new file mode 100644 (file)
index 0000000..e6ebaf2
--- /dev/null
@@ -0,0 +1,7 @@
+/* Test for strftime format attributes: can't have first_arg_num != 0.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat" } */
+
+extern void foo0 (const char *) __attribute__((__format__(__strftime__, 1, 0)));
+extern void foo1 (const char *, ...) __attribute__((__format__(__strftime__, 1, 2))); /* { dg-error "cannot format" "strftime first_arg_num != 0" } */
diff --git a/gcc/testsuite/gcc.dg/format/branch-1.c b/gcc/testsuite/gcc.dg/format/branch-1.c
new file mode 100644 (file)
index 0000000..6ff4131
--- /dev/null
@@ -0,0 +1,29 @@
+/* Test for format checking of conditional expressions.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat" } */
+
+#define NULL ((void *)0)
+
+extern int printf (const char *, ...);
+
+void
+foo (long l, int nfoo)
+{
+  printf ((nfoo > 1) ? "%d foos" : "%d foo", nfoo);
+  printf ((l > 1) ? "%d foos" : "%d foo", l); /* { dg-warning "int format" "wrong type in conditional expr" } */
+  printf ((l > 1) ? "%ld foos" : "%d foo", l); /* { dg-warning "int format" "wrong type in conditional expr" } */
+  printf ((l > 1) ? "%d foos" : "%ld foo", l); /* { dg-warning "int format" "wrong type in conditional expr" } */
+  /* Should allow one case to have extra arguments.  */
+  printf ((nfoo > 1) ? "%d foos" : "1 foo", nfoo);
+  printf ((nfoo > 1) ? "many foos" : "1 foo", nfoo); /* { dg-warning "too many" "too many args in all branches" } */
+  printf ((nfoo > 1) ? "%d foos" : "", nfoo);
+  printf ((nfoo > 1) ? "%d foos" : ((nfoo > 0) ? "1 foo" : "no foos"), nfoo);
+  printf ((nfoo > 1) ? "%d foos" : ((nfoo > 0) ? "%d foo" : "%d foos"), nfoo);
+  printf ((nfoo > 1) ? "%d foos" : ((nfoo > 0) ? "%d foo" : "%ld foos"), nfoo); /* { dg-warning "long int format" "wrong type" } */
+  printf ((nfoo > 1) ? "%ld foos" : ((nfoo > 0) ? "%d foo" : "%d foos"), nfoo); /* { dg-warning "long int format" "wrong type" } */
+  printf ((nfoo > 1) ? "%d foos" : ((nfoo > 0) ? "%ld foo" : "%d foos"), nfoo); /* { dg-warning "long int format" "wrong type" } */
+  /* Extra arguments to NULL should be complained about.  */
+  printf (NULL, "foo"); /* { dg-warning "too many" "NULL extra args" } */
+  /* { dg-warning "null" "null format arg" { target *-*-* } 27 } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c90-printf-1.c b/gcc/testsuite/gcc.dg/format/c90-printf-1.c
new file mode 100644 (file)
index 0000000..5058066
--- /dev/null
@@ -0,0 +1,249 @@
+/* Test for printf formats.  Formats using C90 features, including cases
+   where C90 specifies some aspect of the format to be ignored or where
+   the behaviour is undefined.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+#ifndef __WINT_TYPE__
+#define __WINT_TYPE__ unsigned int
+#endif
+typedef __WINT_TYPE__ wint_t;
+
+__extension__ typedef long long int llong;
+__extension__ typedef unsigned long long int ullong;
+
+extern int printf (const char *, ...);
+
+#define NULL ((void *)0)
+
+void
+foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
+     int *n, short int *hn, long int l, unsigned long int ul,
+     long int *ln, long double ld, wint_t lc, wchar_t *ls, llong ll,
+     ullong ull, unsigned int *un, const int *cn, signed char *ss,
+     unsigned char *us, const signed char *css, unsigned int u1,
+     unsigned int u2)
+{
+  /* See ISO/IEC 9899:1990 (E) subclause 7.9.6.1 (pages 131-134).  */
+  /* Basic sanity checks for the different components of a format.  */
+  printf ("%d\n", i);
+  printf ("%+d\n", i);
+  printf ("%3d\n", i);
+  printf ("%-3d\n", i);
+  printf ("%.7d\n", i);
+  printf ("%+9.4d\n", i);
+  printf ("%.3ld\n", l);
+  printf ("%*d\n", i1, i);
+  printf ("%.*d\n", i2, i);
+  printf ("%*.*ld\n", i1, i2, l);
+  printf ("%d %lu\n", i, ul);
+  /* GCC has objected to the next one in the past, but it is a valid way
+     of specifying zero precision.
+  */
+  printf ("%.e\n", d); /* { dg-bogus "precision" "bogus precision warning" } */
+  /* Bogus use of width.  */
+  printf ("%5n\n", n); /* { dg-warning "width" "width with %n" } */
+  /* Erroneous, ignored or pointless constructs with precision.  */
+  /* Whether negative values for precision may be included in the format
+     string is not entirely clear; presume not, following Clive Feather's
+     proposed resolution to DR#220 against C99.  In any case, such a
+     construct should be warned about.
+  */
+  printf ("%.-5d\n", i); /* { dg-warning "format|precision" "negative precision warning" } */
+  printf ("%.-*d\n", i); /* { dg-warning "format" "broken %.-*d format" } */
+  printf ("%.3c\n", i); /* { dg-warning "precision" "precision with %c" } */
+  printf ("%.3p\n", p); /* { dg-warning "precision" "precision with %p" } */
+  printf ("%.3n\n", n); /* { dg-warning "precision" "precision with %n" } */
+  /* Valid and invalid %% constructions.  Some of the warning messages
+     are non-optimal, but they do detect the errorneous nature of the
+     format string.
+  */
+  printf ("%%");
+  printf ("%.3%"); /* { dg-warning "format" "bogus %%" } */
+  printf ("%-%"); /* { dg-warning "format" "bogus %%" } */
+  printf ("%-%\n"); /* { dg-warning "format" "bogus %%" } */
+  printf ("%5%\n"); /* { dg-warning "format" "bogus %%" } */
+  printf ("%h%\n"); /* { dg-warning "format" "bogus %%" } */
+  /* Valid and invalid %h, %l, %L constructions.  */
+  printf ("%hd", i);
+  printf ("%hi", i);
+  /* Strictly, these parameters should be int or unsigned int according to
+     what unsigned short promotes to.  However, GCC ignores sign
+     differences in format checking here, and this is relied on to get the
+     correct checking without print_char_table needing to know whether
+     int and short are the same size.
+  */
+  printf ("%ho%hu%hx%hX", u, u, u, u);
+  printf ("%hn", hn);
+  printf ("%hf", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%he", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hE", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hg", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hG", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hc", i); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hs", s); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hp", p); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%h"); /* { dg-warning "conversion lacks type" "bare %h" } */
+  printf ("%h."); /* { dg-warning "conversion" "bogus %h." } */
+  printf ("%ld%li%lo%lu%lx%lX", l, l, ul, ul, ul, ul);
+  printf ("%ln", ln);
+  printf ("%lf", d); /* { dg-warning "length|C" "bad use of %l" } */
+  printf ("%le", d); /* { dg-warning "length|C" "bad use of %l" } */
+  printf ("%lE", d); /* { dg-warning "length|C" "bad use of %l" } */
+  printf ("%lg", d); /* { dg-warning "length|C" "bad use of %l" } */
+  printf ("%lG", d); /* { dg-warning "length|C" "bad use of %l" } */
+  printf ("%lp", p); /* { dg-warning "length|C" "bad use of %l" } */
+  /* These next two were added in C94, but should be objected to in C90.
+     For the first one, GCC has wanted wchar_t instead of the correct C94
+     and C99 wint_t.
+  */
+  printf ("%lc", lc); /* { dg-warning "length|C" "C90 bad use of %l" } */
+  printf ("%ls", ls); /* { dg-warning "length|C" "C90 bad use of %l" } */
+  /* These uses of %L are legitimate, though GCC has wrongly warned for
+     them in the past.
+  */
+  printf ("%Le%LE%Lf%Lg%LG", ld, ld, ld, ld, ld);
+  /* These next six are accepted by GCC as referring to long long,
+     but -pedantic correctly warns.
+  */
+  printf ("%Ld", ll); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%Li", ll); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%Lo", ull); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%Lu", ull); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%Lx", ull); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%LX", ull); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%Lc", i); /* { dg-warning "length" "bad use of %L" } */
+  printf ("%Ls", s); /* { dg-warning "length" "bad use of %L" } */
+  printf ("%Lp", p); /* { dg-warning "length" "bad use of %L" } */
+  printf ("%Ln", n); /* { dg-warning "length" "bad use of %L" } */
+  /* Valid uses of each bare conversion.  */
+  printf ("%d%i%o%u%x%X%f%e%E%g%G%c%s%p%n%%", i, i, u, u, u, u, d, d, d, d, d,
+         i, s, p, n);
+  /* Uses of the - flag (valid on all non-%, non-n conversions).  */
+  printf ("%-d%-i%-o%-u%-x%-X%-f%-e%-E%-g%-G%-c%-s%-p", i, i, u, u, u, u,
+         d, d, d, d, d, i, s, p);
+  printf ("%-n", n); /* { dg-warning "flag" "bad use of %-n" } */
+  /* Uses of the + flag (valid on signed conversions only).  */
+  printf ("%+d%+i%+f%+e%+E%+g%+G\n", i, i, d, d, d, d, d);
+  printf ("%+o", u); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+u", u); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+x", u); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+X", u); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+c", i); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+s", s); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+p", p); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+n", n); /* { dg-warning "flag" "bad use of + flag" } */
+  /* Uses of the space flag (valid on signed conversions only, and ignored
+     with +).
+  */
+  printf ("% +d", i); /* { dg-warning "use of both|ignored" "use of space and + flags" } */
+  printf ("%+ d", i); /* { dg-warning "use of both|ignored" "use of space and + flags" } */
+  printf ("% d% i% f% e% E% g% G\n", i, i, d, d, d, d, d);
+  printf ("% o", u); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% u", u); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% x", u); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% X", u); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% c", i); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% s", s); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% p", p); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% n", n); /* { dg-warning "flag" "bad use of space flag" } */
+  /* Uses of the # flag.  */
+  printf ("%#o%#x%#X%#e%#E%#f%#g%#G", u, u, u, d, d, d, d, d);
+  printf ("%#d", i); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#i", i); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#u", u); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#c", i); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#s", s); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#p", p); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#n", n); /* { dg-warning "flag" "bad use of # flag" } */
+  /* Uses of the 0 flag.  */
+  printf ("%08d%08i%08o%08u%08x%08X%08e%08E%08f%08g%08G", i, i, u, u, u, u,
+         d, d, d, d, d);
+  printf ("%0c", i); /* { dg-warning "flag" "bad use of 0 flag" } */
+  printf ("%0s", s); /* { dg-warning "flag" "bad use of 0 flag" } */
+  printf ("%0p", p); /* { dg-warning "flag" "bad use of 0 flag" } */
+  printf ("%0n", n); /* { dg-warning "flag" "bad use of 0 flag" } */
+  /* 0 flag ignored with precision for certain types, not others.  */
+  printf ("%08.5d", i); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5i", i); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5o", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5u", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5x", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5X", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5f%08.5e%08.5E%08.5g%08.5G", d, d, d, d, d);
+  /* 0 flag ignored with - flag.  */
+  printf ("%-08d", i); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08i", i); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08o", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08u", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08x", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08X", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08e", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08E", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08f", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08g", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08G", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  /* Various tests of bad argument types.  */
+  printf ("%d", l); /* { dg-warning "format" "bad argument types" } */
+  printf ("%*.*d", l, i2, i); /* { dg-warning "field" "bad * argument types" } */
+  printf ("%*.*d", i1, l, i); /* { dg-warning "field" "bad * argument types" } */
+  printf ("%ld", i); /* { dg-warning "format" "bad argument types" } */
+  printf ("%s", n); /* { dg-warning "format" "bad argument types" } */
+  printf ("%p", i); /* { dg-warning "format" "bad argument types" } */
+  printf ("%n", p); /* { dg-warning "format" "bad argument types" } */
+  /* With -pedantic, we want some further checks for pointer targets:
+     %p should allow only pointers to void (possibly qualified) and
+     to character types (possibly qualified), but not function pointers
+     or pointers to other types.  (Whether, in fact, character types are
+     allowed here is unclear; see thread on comp.std.c, July 2000 for
+     discussion of the requirements of rules on identical representation,
+     and of the application of the as if rule with the new va_arg
+     allowances in C99 to printf.)  Likewise, we should warn if
+     pointer targets differ in signedness, except in some circumstances
+     for character pointers.  (In C99 we should consider warning for
+     char * or unsigned char * being passed to %hhn, even if strictly
+     legitimate by the standard.)
+  */
+  printf ("%p", foo); /* { dg-warning "format" "bad argument types" } */
+  printf ("%n", un); /* { dg-warning "format" "bad argument types" } */
+  printf ("%p", n); /* { dg-warning "format" "bad argument types" } */
+  /* Allow character pointers with %p.  */
+  printf ("%p%p%p%p", s, ss, us, css);
+  /* %s allows any character type.  */
+  printf ("%s%s%s%s", s, ss, us, css);
+  /* Warning for void * arguments for %s is GCC's historical behaviour,
+     and seems useful to keep, even if some standard versions might be
+     read to permit it.
+  */
+  printf ("%s", p); /* { dg-warning "format" "bad argument types" } */
+  /* The historical behaviour is to allow signed / unsigned types
+     interchangably as arguments.  For values representable in both types,
+     such usage may be correct.  For now preserve the behaviour of GCC
+     in such cases.
+  */
+  printf ("%d", u);
+  /* Also allow the same for width and precision arguments.  In the past,
+     GCC has been inconsistent and allowed unsigned for width but not
+     precision.
+  */
+  printf ("%*.*d", u1, u2, i);
+  /* Wrong number of arguments.  */
+  printf ("%d%d", i); /* { dg-warning "arguments" "wrong number of args" } */
+  printf ("%d", i, i); /* { dg-warning "arguments" "wrong number of args" } */
+  /* Miscellaneous bogus constructions.  */
+  printf (""); /* { dg-warning "zero-length" "warning for empty format" } */
+  printf ("\0"); /* { dg-warning "embedded" "warning for embedded NUL" } */
+  printf ("%d\0", i); /* { dg-warning "embedded" "warning for embedded NUL" } */
+  printf ("%d\0%d", i, i); /* { dg-warning "embedded|too many" "warning for embedded NUL" } */
+  printf (NULL); /* { dg-warning "null" "null format string warning" } */
+  printf ("%"); /* { dg-warning "trailing" "trailing % warning" } */
+  printf ("%++d", i); /* { dg-warning "repeated" "repeated flag warning" } */
+  printf ("%n", cn); /* { dg-warning "constant" "%n with const" } */
+  printf ((const char *)L"foo"); /* { dg-warning "wide" "wide string" } */
+  printf ("%n", (int *)0); /* { dg-warning "null" "%n with NULL" } */
+  printf ("%s", (char *)0); /* { dg-warning "null" "%s with NULL" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c90-printf-2.c b/gcc/testsuite/gcc.dg/format/c90-printf-2.c
new file mode 100644 (file)
index 0000000..1f8c544
--- /dev/null
@@ -0,0 +1,50 @@
+/* Test for printf formats.  Formats using C99 features should be rejected
+   outside of C99 mode.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+
+__extension__ typedef long long int llong;
+
+/* This next definition is a kludge.  When GCC has a <stdint.h> it
+   should be used.
+*/
+/* (T *) if E is zero, (void *) otherwise.  */
+#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E))
+
+/* (T *) if E is nonzero, (void *) otherwise.  */
+#define type_if(T, E) type_if_not(T, !(E))
+
+/* Combine pointer types, all but one (void *).  */
+#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0)
+#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3))
+
+#define maybe_int_ptr type_if(int, sizeof(int) == sizeof(llong))
+#define maybe_long_ptr type_if(long, sizeof(long) == sizeof(llong) && sizeof(long) > sizeof(int))
+#define maybe_long_long_ptr type_if(llong, sizeof(llong) > sizeof(long))
+
+#define intmax_type_ptr type_comb3(maybe_int_ptr, maybe_long_ptr, maybe_long_long_ptr)
+
+typedef __typeof__(*((intmax_type_ptr)0)) intmax_t;
+
+extern int printf (const char *, ...);
+
+void
+foo (int i, double d, llong ll, intmax_t j, size_t z, ptrdiff_t t)
+{
+  /* Some tests already in c90-printf-1.c, e.g. %lf.  */
+  /* The widths hh, ll, j, z, t are new.  */
+  printf ("%hhd", i); /* { dg-warning "length|C" "%hh in C90" } */
+  printf ("%lld", ll); /* { dg-warning "length|C" "%ll in C90" } */
+  printf ("%jd", j); /* { dg-warning "length|C" "%j in C90" } */
+  printf ("%zu", z); /* { dg-warning "length|C" "%z in C90" } */
+  printf ("%td", t); /* { dg-warning "length|C" "%t in C90" } */
+  /* The formats F, a, A are new.  */
+  printf ("%F", d); /* { dg-warning "C" "%F in C90" } */
+  printf ("%a", d); /* { dg-warning "C" "%a in C90" } */
+  printf ("%A", d); /* { dg-warning "C" "%A in C90" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c90-printf-3.c b/gcc/testsuite/gcc.dg/format/c90-printf-3.c
new file mode 100644 (file)
index 0000000..119cdee
--- /dev/null
@@ -0,0 +1,60 @@
+/* Test for printf formats.  Test that the C90 functions get their default
+   attributes in strict C90 mode, but the C99 and gettext functions
+   do not.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
+
+/* This may not be correct in the particular case, but allows the
+   prototypes to be declared, and we don't try to link.
+*/
+typedef struct _FILE FILE;
+extern FILE *stdout;
+
+typedef __SIZE_TYPE__ size_t;
+typedef __builtin_va_list va_list;
+
+extern int fprintf (FILE *, const char *, ...);
+extern int printf (const char *, ...);
+extern int sprintf (char *, const char *, ...);
+extern int vfprintf (FILE *, const char *, va_list);
+extern int vprintf (const char *, va_list);
+extern int vsprintf (char *, const char *, va_list);
+
+extern int snprintf (char *, size_t, const char *, ...);
+extern int vsnprintf (char *, size_t, const char *, va_list);
+
+extern char *gettext (const char *);
+extern char *dgettext (const char *, const char *);
+extern char *dcgettext (const char *, const char *, int);
+
+void
+foo (int i, char *s, size_t n, va_list v0, va_list v1, va_list v2, va_list v3,
+     va_list v4, va_list v5, va_list v6, va_list v7, va_list v8)
+{
+  fprintf (stdout, "%d", i);
+  fprintf (stdout, "%ld", i); /* { dg-warning "format" "fprintf" } */
+  printf ("%d", i);
+  printf ("%ld", i); /* { dg-warning "format" "printf" } */
+  sprintf (s, "%d", i);
+  sprintf (s, "%ld", i); /* { dg-warning "format" "sprintf" } */
+  vfprintf (stdout, "%d", v0);
+  vfprintf (stdout, "%Y", v1); /* { dg-warning "format" "vfprintf" } */
+  vprintf ("%d", v2);
+  vprintf ("%Y", v3); /* { dg-warning "format" "vprintf" } */
+  /* The following used to give a bogus warning.  */
+  vprintf ("%*.*d", v8);
+  vsprintf (s, "%d", v4);
+  vsprintf (s, "%Y", v5); /* { dg-warning "format" "vsprintf" } */
+  snprintf (s, n, "%d", i);
+  snprintf (s, n, "%ld", i);
+  vsnprintf (s, n, "%d", v6);
+  vsnprintf (s, n, "%Y", v7);
+  printf (gettext ("%d"), i);
+  printf (gettext ("%ld"), i);
+  printf (dgettext ("", "%d"), i);
+  printf (dgettext ("", "%ld"), i);
+  printf (dcgettext ("", "%d", 0), i);
+  printf (dcgettext ("", "%ld", 0), i);
+}
diff --git a/gcc/testsuite/gcc.dg/format/c90-scanf-1.c b/gcc/testsuite/gcc.dg/format/c90-scanf-1.c
new file mode 100644 (file)
index 0000000..922a7a7
--- /dev/null
@@ -0,0 +1,126 @@
+/* Test for scanf formats.  Formats using C90 features, including cases
+   where C90 specifies some aspect of the format to be ignored or where
+   the behaviour is undefined.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+__extension__ typedef long long int llong;
+__extension__ typedef unsigned long long int ullong;
+
+extern int scanf (const char *, ...);
+
+#define NULL ((void *)0)
+
+void
+foo (int *ip, unsigned int *uip, short int *hp, unsigned short int *uhp,
+     long int *lp, unsigned long int *ulp, float *fp, double *dp,
+     long double *ldp, char *s, signed char *ss, unsigned char *us,
+     void **pp, int *n, llong *llp, ullong *ullp, wchar_t *ls,
+     const int *cip, const int *cn, const char *cs, const void **ppc,
+     void *const *pcp, short int *hn, long int *ln, void *p, char **sp,
+     volatile void *ppv)
+{
+  /* See ISO/IEC 9899:1990 (E) subclause 7.9.6.2 (pages 134-138).  */
+  /* Basic sanity checks for the different components of a format.  */
+  scanf ("%d", ip);
+  scanf ("%*d");
+  scanf ("%3d", ip);
+  scanf ("%hd", hp);
+  scanf ("%3ld", lp);
+  scanf ("%*3d");
+  scanf ("%d %ld", ip, lp);
+  /* Valid and invalid %% constructions.  */
+  scanf ("%%");
+  scanf ("%*%"); /* { dg-warning "format" "bogus %%" } */
+  scanf ("%*%\n"); /* { dg-warning "format" "bogus %%" } */
+  scanf ("%4%"); /* { dg-warning "format" "bogus %%" } */
+  scanf ("%4%\n"); /* { dg-warning "format" "bogus %%" } */
+  scanf ("%h%"); /* { dg-warning "format" "bogus %%" } */
+  scanf ("%h%\n"); /* { dg-warning "format" "bogus %%" } */
+  /* Valid, invalid and silly assignment-suppression constructions.  */
+  scanf ("%*d%*i%*o%*u%*x%*X%*e%*E%*f%*g%*G%*s%*[abc]%*c%*p");
+  scanf ("%*2d%*8s%*3c");
+  scanf ("%*n", n); /* { dg-warning "suppress" "suppression of %n" } */
+  scanf ("%*hd"); /* { dg-warning "together" "suppression with length" } */
+  /* Valid, invalid and silly width constructions.  */
+  scanf ("%2d%3i%4o%5u%6x%7X%8e%9E%10f%11g%12G%13s%14[abc]%15c%16p",
+        ip, ip, uip, uip, uip, uip, fp, fp, fp, fp, fp, s, s, s, pp);
+  scanf ("%0d", ip); /* { dg-warning "width" "warning for zero width" } */
+  scanf ("%3n", n); /* { dg-warning "width" "width with %n" } */
+  /* Valid and invalid %h, %l, %L constructions.  */
+  scanf ("%hd%hi%ho%hu%hx%hX%hn", hp, hp, uhp, uhp, uhp, uhp, hn);
+  scanf ("%he", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hE", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hf", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hg", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hG", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hs", s); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%h[ac]", s); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hc", s); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hp", pp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%h"); /* { dg-warning "conversion lacks type" "bare %h" } */
+  scanf ("%h."); /* { dg-warning "conversion" "bogus %h" } */
+  scanf ("%ld%li%lo%lu%lx%lX%ln", lp, lp, ulp, ulp, ulp, ulp, ln);
+  scanf ("%le%lE%lf%lg%lG", dp, dp, dp, dp, dp);
+  scanf ("%lp", pp); /* { dg-warning "length" "bad use of %l" } */
+  /* These next three formats were added in C94.  */
+  scanf ("%ls", ls); /* { dg-warning "length|C" "bad use of %l" } */
+  scanf ("%l[ac]", ls); /* { dg-warning "length|C" "bad use of %l" } */
+  scanf ("%lc", ls); /* { dg-warning "length|C" "bad use of %l" } */
+  scanf ("%Le%LE%Lf%Lg%LG", ldp, ldp, ldp, ldp, ldp);
+  scanf ("%Ld", llp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%Li", llp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%Lo", ullp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%Lu", ullp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%Lx", ullp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%LX", ullp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%Ls", s); /* { dg-warning "length" "bad use of %L" } */
+  scanf ("%L[ac]", s); /* { dg-warning "length" "bad use of %L" } */
+  scanf ("%Lc", s); /* { dg-warning "length" "bad use of %L" } */
+  scanf ("%Lp", pp); /* { dg-warning "length" "bad use of %L" } */
+  scanf ("%Ln", n); /* { dg-warning "length" "bad use of %L" } */
+  /* Valid uses of each bare conversion.  */
+  scanf ("%d%i%o%u%x%X%e%E%f%g%G%s%[abc]%c%p%n%%", ip, ip, uip, uip, uip,
+        uip, fp, fp, fp, fp, fp, s, s, s, pp, n);
+  /* Allow other character pointers with %s, %c, %[].  */
+  scanf ("%2s%3s%4c%5c%6[abc]%7[abc]", ss, us, ss, us, ss, us);
+  /* Further tests for %[].  */
+  scanf ("%[%d]%d", s, ip);
+  scanf ("%[^%d]%d", s, ip);
+  scanf ("%[]%d]%d", s, ip);
+  scanf ("%[^]%d]%d", s, ip);
+  scanf ("%[%d]%d", s, ip);
+  scanf ("%[]abcd", s); /* { dg-warning "no closing" "incomplete scanset" } */
+  /* Various tests of bad argument types.  Some of these are only pedantic
+     warnings.
+  */
+  scanf ("%d", lp); /* { dg-warning "format" "bad argument types" } */
+  scanf ("%d", uip); /* { dg-warning "format" "bad argument types" } */
+  scanf ("%d", pp); /* { dg-warning "format" "bad argument types" } */
+  scanf ("%p", ppc); /* { dg-warning "format" "bad argument types" } */
+  scanf ("%p", ppv); /* { dg-warning "format" "bad argument types" } */
+  scanf ("%s", n); /* { dg-warning "format" "bad argument types" } */
+  scanf ("%s", p); /* { dg-warning "format" "bad argument types" } */
+  scanf ("%p", p); /* { dg-warning "format" "bad argument types" } */
+  scanf ("%p", sp); /* { dg-warning "format" "bad argument types" } */
+  /* Tests for writing into constant values.  */
+  scanf ("%d", cip); /* { dg-warning "constant" "%d writing into const" } */
+  scanf ("%n", cn); /* { dg-warning "constant" "%n writing into const" } */
+  scanf ("%s", cs); /* { dg-warning "constant" "%s writing into const" } */
+  scanf ("%p", pcp); /* { dg-warning "constant" "%p writing into const" } */
+  /* Wrong number of arguments.  */
+  scanf ("%d%d", ip); /* { dg-warning "arguments" "wrong number of args" } */
+  scanf ("%d", ip, ip); /* { dg-warning "arguments" "wrong number of args" } */
+  /* Miscellaneous bogus constructions.  */
+  scanf (""); /* { dg-warning "zero-length" "warning for empty format" } */
+  scanf ("\0"); /* { dg-warning "embedded" "warning for embedded NUL" } */
+  scanf ("%d\0", ip); /* { dg-warning "embedded" "warning for embedded NUL" } */
+  scanf ("%d\0%d", ip, ip); /* { dg-warning "embedded|too many" "warning for embedded NUL" } */
+  scanf (NULL); /* { dg-warning "null" "null format string warning" } */
+  scanf ("%"); /* { dg-warning "trailing" "trailing % warning" } */
+  scanf ("%d", (int *)0); /* { dg-warning "null" "writing into NULL" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c90-scanf-2.c b/gcc/testsuite/gcc.dg/format/c90-scanf-2.c
new file mode 100644 (file)
index 0000000..786acdd
--- /dev/null
@@ -0,0 +1,51 @@
+/* Test for scanf formats.  Formats using C99 features should be rejected
+   outside of C99 mode.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+
+__extension__ typedef long long int llong;
+
+/* This next definition is a kludge.  When GCC has a <stdint.h> it
+   should be used.
+*/
+/* (T *) if E is zero, (void *) otherwise.  */
+#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E))
+
+/* (T *) if E is nonzero, (void *) otherwise.  */
+#define type_if(T, E) type_if_not(T, !(E))
+
+/* Combine pointer types, all but one (void *).  */
+#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0)
+#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3))
+
+#define maybe_int_ptr type_if(int, sizeof(int) == sizeof(llong))
+#define maybe_long_ptr type_if(long, sizeof(long) == sizeof(llong) && sizeof(long) > sizeof(int))
+#define maybe_long_long_ptr type_if(llong, sizeof(llong) > sizeof(long))
+
+#define intmax_type_ptr type_comb3(maybe_int_ptr, maybe_long_ptr, maybe_long_long_ptr)
+
+typedef __typeof__(*((intmax_type_ptr)0)) intmax_t;
+
+extern int scanf (const char *, ...);
+
+void
+foo (signed char *hhp, float *fp, llong *llp, intmax_t *jp,
+     size_t *zp, ptrdiff_t *tp)
+{
+  /* Some tests already in c90-scanf-1.c.  */
+  /* The widths hh, ll, j, z, t are new.  */
+  scanf ("%hhd", hhp); /* { dg-warning "length|C" "%hh in C90" } */
+  scanf ("%lld", llp); /* { dg-warning "length|C" "%ll in C90" } */
+  scanf ("%jd", jp); /* { dg-warning "length|C" "%j in C90" } */
+  scanf ("%zu", zp); /* { dg-warning "length|C" "%z in C90" } */
+  scanf ("%td", tp); /* { dg-warning "length|C" "%t in C90" } */
+  /* The formats F, a, A are new.  */
+  scanf ("%F", fp); /* { dg-warning "C" "%F in C90" } */
+  scanf ("%a", fp); /* { dg-warning "C" "%a in C90" } */
+  scanf ("%A", fp); /* { dg-warning "C" "%A in C90" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c90-scanf-3.c b/gcc/testsuite/gcc.dg/format/c90-scanf-3.c
new file mode 100644 (file)
index 0000000..147a222
--- /dev/null
@@ -0,0 +1,21 @@
+/* Test for scanf formats.  Formats using extensions to the standard
+   should be rejected in strict pedantic mode.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+extern int scanf (const char *, ...);
+
+void
+foo (char **sp, wchar_t **lsp)
+{
+  /* %a formats for allocation, only recognised in C90 mode, are a
+     GNU extension.
+  */
+  scanf ("%as", sp); /* { dg-warning "C" "%as" } */
+  scanf ("%aS", lsp); /* { dg-warning "C" "%aS" } */
+  scanf ("%a[bcd]", sp); /* { dg-warning "C" "%a[]" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c90-scanf-4.c b/gcc/testsuite/gcc.dg/format/c90-scanf-4.c
new file mode 100644 (file)
index 0000000..3bbe66e
--- /dev/null
@@ -0,0 +1,51 @@
+/* Test for scanf formats.  Test that the C90 functions get their default
+   attributes in strict C90 mode, but the C99 and gettext functions
+   do not.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
+
+/* This may not be correct in the particular case, but allows the
+   prototypes to be declared, and we don't try to link.
+*/
+typedef struct _FILE FILE;
+extern FILE *stdin;
+
+typedef __builtin_va_list va_list;
+
+extern int fscanf (FILE *, const char *, ...);
+extern int scanf (const char *, ...);
+extern int sscanf (const char *, const char *, ...);
+
+extern int vfscanf (FILE *, const char *, va_list);
+extern int vscanf (const char *, va_list);
+extern int vsscanf (const char *, const char *, va_list);
+
+extern char *gettext (const char *);
+extern char *dgettext (const char *, const char *);
+extern char *dcgettext (const char *, const char *, int);
+
+void
+foo (int *ip, char *s, va_list v0, va_list v1, va_list v2, va_list v3,
+     va_list v4, va_list v5)
+{
+  fscanf (stdin, "%d", ip);
+  fscanf (stdin, "%ld", ip); /* { dg-warning "format" "fscanf" } */
+  scanf ("%d", ip);
+  scanf ("%ld", ip); /* { dg-warning "format" "scanf" } */
+  sscanf (s, "%d", ip);
+  sscanf (s, "%ld", ip); /* { dg-warning "format" "sscanf" } */
+  vfscanf (stdin, "%d", v0);
+  vfscanf (stdin, "%Y", v1);
+  vscanf ("%d", v2);
+  vscanf ("%Y", v3);
+  vsscanf (s, "%d", v4);
+  vsscanf (s, "%Y", v5);
+  scanf (gettext ("%d"), ip);
+  scanf (gettext ("%ld"), ip);
+  scanf (dgettext ("", "%d"), ip);
+  scanf (dgettext ("", "%ld"), ip);
+  scanf (dcgettext ("", "%d", 0), ip);
+  scanf (dcgettext ("", "%ld", 0), ip);
+}
diff --git a/gcc/testsuite/gcc.dg/format/c90-strftime-1.c b/gcc/testsuite/gcc.dg/format/c90-strftime-1.c
new file mode 100644 (file)
index 0000000..6a13d5e
--- /dev/null
@@ -0,0 +1,23 @@
+/* Test for strftime formats.  Formats using C90 features.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+struct tm;
+
+extern size_t strftime (char *, size_t, const char *, const struct tm *);
+
+void
+foo (char *s, size_t m, const struct tm *tp)
+{
+  /* See ISO/IEC 9899:1990 (E) subclause 7.12.3.5 (pages 174-175).  */
+  /* Formats which are Y2K-compliant (no 2-digit years).  */
+  strftime (s, m, "%a%A%b%B%d%H%I%j%m%M%p%S%U%w%W%X%Y%Z%%", tp);
+  /* Formats with 2-digit years.  */
+  strftime (s, m, "%y", tp); /* { dg-warning "only last 2" "2-digit year" } */
+  /* Formats with 2-digit years in some locales.  */
+  strftime (s, m, "%c", tp); /* { dg-warning "some locales" "2-digit year" } */
+  strftime (s, m, "%x", tp); /* { dg-warning "some locales" "2-digit year" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c90-strftime-2.c b/gcc/testsuite/gcc.dg/format/c90-strftime-2.c
new file mode 100644 (file)
index 0000000..4d6c289
--- /dev/null
@@ -0,0 +1,35 @@
+/* Test for strftime formats.  Rejection of formats using C99 features in
+   pedantic C90 mode.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+struct tm;
+
+extern size_t strftime (char *, size_t, const char *, const struct tm *);
+
+void
+foo (char *s, size_t m, const struct tm *tp)
+{
+  strftime (s, m, "%C", tp); /* { dg-warning "C" "%C not in C90" } */
+  strftime (s, m, "%D", tp); /* { dg-warning "C" "%D not in C90" } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 17 } */
+  strftime (s, m, "%e", tp); /* { dg-warning "C" "%e not in C90" } */
+  strftime (s, m, "%F", tp); /* { dg-warning "C" "%F not in C90" } */
+  strftime (s, m, "%g", tp); /* { dg-warning "C" "%g not in C90" } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 21 } */
+  strftime (s, m, "%G", tp); /* { dg-warning "C" "%G not in C90" } */
+  strftime (s, m, "%h", tp); /* { dg-warning "C" "%h not in C90" } */
+  strftime (s, m, "%n", tp); /* { dg-warning "C" "%n not in C90" } */
+  strftime (s, m, "%r", tp); /* { dg-warning "C" "%r not in C90" } */
+  strftime (s, m, "%R", tp); /* { dg-warning "C" "%R not in C90" } */
+  strftime (s, m, "%t", tp); /* { dg-warning "C" "%t not in C90" } */
+  strftime (s, m, "%T", tp); /* { dg-warning "C" "%T not in C90" } */
+  strftime (s, m, "%u", tp); /* { dg-warning "C" "%u not in C90" } */
+  strftime (s, m, "%V", tp); /* { dg-warning "C" "%V not in C90" } */
+  strftime (s, m, "%z", tp); /* { dg-warning "C" "%z not in C90" } */
+  strftime (s, m, "%EX", tp); /* { dg-warning "C" "%E not in C90" } */
+  strftime (s, m, "%OW", tp); /* { dg-warning "C" "%O not in C90" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c94-printf-1.c b/gcc/testsuite/gcc.dg/format/c94-printf-1.c
new file mode 100644 (file)
index 0000000..449a342
--- /dev/null
@@ -0,0 +1,25 @@
+/* Test for printf formats.  Changes in C94 to C90.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:199409 -pedantic -Wformat" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+#ifndef __WINT_TYPE__
+#define __WINT_TYPE__ unsigned int
+#endif
+typedef __WINT_TYPE__ wint_t;
+
+extern int printf (const char *, ...);
+
+void
+foo (wint_t lc, wchar_t *ls)
+{
+  /* See ISO/IEC 9899:1990 (E) subclause 7.9.6.1 (pages 131-134),
+     as amended by ISO/IEC 9899:1990/Amd.1:1995 (E) (pages 4-5).
+     We do not repeat here all the C90 format checks, but just verify
+     that %ls and %lc are accepted without warning.
+  */
+  printf ("%lc", lc);
+  printf ("%ls", ls);
+}
diff --git a/gcc/testsuite/gcc.dg/format/c94-scanf-1.c b/gcc/testsuite/gcc.dg/format/c94-scanf-1.c
new file mode 100644 (file)
index 0000000..884cd28
--- /dev/null
@@ -0,0 +1,19 @@
+/* Test for scanf formats.  Changes in C94 to C90.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:199409 -pedantic -Wformat" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+extern int scanf (const char *, ...);
+
+void
+foo (wchar_t *ls)
+{
+  /* See ISO/IEC 9899:1990 (E) subclause 7.9.6.2 (pages 134-138),
+     as amended by ISO/IEC 9899:1990/Amd.1:1995 (E) (pages 5-6).
+     We do not repeat here all the C90 format checks, but just verify
+     that %ls, %lc, %l[] are accepted without warning.
+  */
+  scanf ("%lc%ls%l[abc]", ls, ls, ls);
+}
diff --git a/gcc/testsuite/gcc.dg/format/c99-printf-1.c b/gcc/testsuite/gcc.dg/format/c99-printf-1.c
new file mode 100644 (file)
index 0000000..179ea6e
--- /dev/null
@@ -0,0 +1,228 @@
+/* Test for printf formats.  Formats using C99 features, including cases
+   where C99 specifies some aspect of the format to be ignored or where
+   the behaviour is undefined.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+typedef __WINT_TYPE__ wint_t;
+typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+
+/* Kludge to get signed type corresponding to size_t.  */
+#define unsigned signed
+typedef __SIZE_TYPE__ signed_size_t;
+#undef unsigned
+
+/* These next definitions are kludges.  When GCC has a <stdint.h> it
+   should be used.
+*/
+#include <limits.h>
+#if INT_MAX == LLONG_MAX
+typedef int intmax_t;
+#elif LONG_MAX == LLONG_MAX
+typedef long intmax_t;
+#else
+typedef long long intmax_t;
+#endif
+#if UINT_MAX == ULLONG_MAX
+typedef unsigned int uintmax_t;
+#elif ULONG_MAX == ULLONG_MAX
+typedef unsigned long uintmax_t;
+#else
+typedef unsigned long long uintmax_t;
+#endif
+
+extern int printf (const char *, ...);
+
+#define NULL ((void *)0)
+
+void
+foo (int i, unsigned int u, double d, char *s, void *p, int *n,
+     long double ld, wint_t lc, wchar_t *ls, long long int ll,
+     unsigned long long int ull, signed char *ss, unsigned char *us,
+     long long int *lln, intmax_t j, uintmax_t uj, intmax_t *jn,
+     size_t z, signed_size_t sz, signed_size_t *zn,
+     ptrdiff_t t, ptrdiff_t *tn)
+{
+  /* See ISO/IEC 9899:1999 (E) subclause 7.19.6.1 (pages 273-281).
+     We do not repeat here most of the checks for correct C90 formats
+     or completely broken formats.
+  */
+  /* Valid and invalid %h, %hh, %l, %ll, %j, %z, %t, %L constructions.  */
+  printf ("%hf", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hF", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%he", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hE", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hg", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hG", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%ha", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hA", d); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hc", i); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hs", s); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hp", p); /* { dg-warning "length" "bad use of %h" } */
+  printf ("%hhd%hhi%hho%hhu%hhx%hhX", i, i, u, u, u, u);
+  printf ("%hhn", ss);
+  printf ("%hhf", d); /* { dg-warning "length" "bad use of %hh" } */
+  printf ("%hhF", d); /* { dg-warning "length" "bad use of %hh" } */
+  printf ("%hhe", d); /* { dg-warning "length" "bad use of %hh" } */
+  printf ("%hhE", d); /* { dg-warning "length" "bad use of %hh" } */
+  printf ("%hhg", d); /* { dg-warning "length" "bad use of %hh" } */
+  printf ("%hhG", d); /* { dg-warning "length" "bad use of %hh" } */
+  printf ("%hha", d); /* { dg-warning "length" "bad use of %hh" } */
+  printf ("%hhA", d); /* { dg-warning "length" "bad use of %hh" } */
+  printf ("%hhc", i); /* { dg-warning "length" "bad use of %hh" } */
+  printf ("%hhs", s); /* { dg-warning "length" "bad use of %hh" } */
+  printf ("%hhp", p); /* { dg-warning "length" "bad use of %hh" } */
+  printf ("%lc", lc);
+  printf ("%ls", ls);
+  printf ("%lf%lF%le%lE%lg%lG%la%lA", d, d, d, d, d, d, d, d);
+  printf ("%lp", p); /* { dg-warning "length|C" "bad use of %l" } */
+  printf ("%lld%lli%llo%llu%llx%llX", ll, ll, ull, ull, ull, ull);
+  printf ("%lln", lln);
+  printf ("%llf", d); /* { dg-warning "length" "bad use of %ll" } */
+  printf ("%llF", d); /* { dg-warning "length" "bad use of %ll" } */
+  printf ("%lle", d); /* { dg-warning "length" "bad use of %ll" } */
+  printf ("%llE", d); /* { dg-warning "length" "bad use of %ll" } */
+  printf ("%llg", d); /* { dg-warning "length" "bad use of %ll" } */
+  printf ("%llG", d); /* { dg-warning "length" "bad use of %ll" } */
+  printf ("%lla", d); /* { dg-warning "length" "bad use of %ll" } */
+  printf ("%llA", d); /* { dg-warning "length" "bad use of %ll" } */
+  printf ("%llc", i); /* { dg-warning "length" "bad use of %ll" } */
+  printf ("%lls", s); /* { dg-warning "length" "bad use of %ll" } */
+  printf ("%llp", p); /* { dg-warning "length" "bad use of %ll" } */
+  printf ("%jd%ji%jo%ju%jx%jX", j, j, uj, uj, uj, uj); /* { dg-bogus "length" "bogus %j warning" { target *-*-* } } */
+  printf ("%jn", jn); /* { dg-bogus "length" "bogus %j warning" { target *-*-* } } */
+  printf ("%jf", d); /* { dg-warning "length" "bad use of %j" } */
+  printf ("%jF", d); /* { dg-warning "length" "bad use of %j" } */
+  printf ("%je", d); /* { dg-warning "length" "bad use of %j" } */
+  printf ("%jE", d); /* { dg-warning "length" "bad use of %j" } */
+  printf ("%jg", d); /* { dg-warning "length" "bad use of %j" } */
+  printf ("%jG", d); /* { dg-warning "length" "bad use of %j" } */
+  printf ("%ja", d); /* { dg-warning "length" "bad use of %j" } */
+  printf ("%jA", d); /* { dg-warning "length" "bad use of %j" } */
+  printf ("%jc", i); /* { dg-warning "length" "bad use of %j" } */
+  printf ("%js", s); /* { dg-warning "length" "bad use of %j" } */
+  printf ("%jp", p); /* { dg-warning "length" "bad use of %j" } */
+  printf ("%zd%zi%zo%zu%zx%zX", sz, sz, z, z, z, z);
+  printf ("%zn", zn);
+  printf ("%zf", d); /* { dg-warning "length" "bad use of %z" } */
+  printf ("%zF", d); /* { dg-warning "length" "bad use of %z" } */
+  printf ("%ze", d); /* { dg-warning "length" "bad use of %z" } */
+  printf ("%zE", d); /* { dg-warning "length" "bad use of %z" } */
+  printf ("%zg", d); /* { dg-warning "length" "bad use of %z" } */
+  printf ("%zG", d); /* { dg-warning "length" "bad use of %z" } */
+  printf ("%za", d); /* { dg-warning "length" "bad use of %z" } */
+  printf ("%zA", d); /* { dg-warning "length" "bad use of %z" } */
+  printf ("%zc", i); /* { dg-warning "length" "bad use of %z" } */
+  printf ("%zs", s); /* { dg-warning "length" "bad use of %z" } */
+  printf ("%zp", p); /* { dg-warning "length" "bad use of %z" } */
+  printf ("%td%ti%to%tu%tx%tX", t, t, t, t, t, t);
+  printf ("%tn", tn);
+  printf ("%tf", d); /* { dg-warning "length" "bad use of %t" } */
+  printf ("%tF", d); /* { dg-warning "length" "bad use of %t" } */
+  printf ("%te", d); /* { dg-warning "length" "bad use of %t" } */
+  printf ("%tE", d); /* { dg-warning "length" "bad use of %t" } */
+  printf ("%tg", d); /* { dg-warning "length" "bad use of %t" } */
+  printf ("%tG", d); /* { dg-warning "length" "bad use of %t" } */
+  printf ("%ta", d); /* { dg-warning "length" "bad use of %t" } */
+  printf ("%tA", d); /* { dg-warning "length" "bad use of %t" } */
+  printf ("%tc", i); /* { dg-warning "length" "bad use of %t" } */
+  printf ("%ts", s); /* { dg-warning "length" "bad use of %t" } */
+  printf ("%tp", p); /* { dg-warning "length" "bad use of %t" } */
+  printf ("%Le%LE%Lf%LF%Lg%LG%La%LA", ld, ld, ld, ld, ld, ld, ld, ld);
+  /* These next six are accepted by GCC as referring to long long,
+     but -pedantic correctly warns.
+  */
+  printf ("%Ld", ll); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%Li", ll); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%Lo", ull); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%Lu", ull); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%Lx", ull); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%LX", ull); /* { dg-warning "does not support" "bad use of %L" } */
+  printf ("%Lc", i); /* { dg-warning "length" "bad use of %L" } */
+  printf ("%Ls", s); /* { dg-warning "length" "bad use of %L" } */
+  printf ("%Lp", p); /* { dg-warning "length" "bad use of %L" } */
+  printf ("%Ln", n); /* { dg-warning "length" "bad use of %L" } */
+  /* Valid uses of each bare conversion.  */
+  printf ("%d%i%o%u%x%X%f%F%e%E%g%G%a%A%c%s%p%n%%", i, i, u, u, u, u,
+         d, d, d, d, d, d, d, d, i, s, p, n);
+  /* Uses of the - flag (valid on all non-%, non-n conversions).  */
+  printf ("%-d%-i%-o%-u%-x%-X%-f%-F%-e%-E%-g%-G%-a%-A%-c%-s%-p", i, i,
+         u, u, u, u, d, d, d, d, d, d, d, d, i, s, p);
+  printf ("%-n", n); /* { dg-warning "flag" "bad use of %-n" } */
+  /* Uses of the + flag (valid on signed conversions only).  */
+  printf ("%+d%+i%+f%+F%+e%+E%+g%+G%+a%+A\n", i, i, d, d, d, d, d, d, d, d);
+  printf ("%+o", u); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+u", u); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+x", u); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+X", u); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+c", i); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+s", s); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+p", p); /* { dg-warning "flag" "bad use of + flag" } */
+  printf ("%+n", n); /* { dg-warning "flag" "bad use of + flag" } */
+  /* Uses of the space flag (valid on signed conversions only, and ignored
+     with +).
+  */
+  printf ("% +d", i); /* { dg-warning "use of both|ignored" "use of space and + flags" } */
+  printf ("%+ d", i); /* { dg-warning "use of both|ignored" "use of space and + flags" } */
+  printf ("% d% i% f% F% e% E% g% G% a% A\n", i, i, d, d, d, d, d, d, d, d);
+  printf ("% o", u); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% u", u); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% x", u); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% X", u); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% c", i); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% s", s); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% p", p); /* { dg-warning "flag" "bad use of space flag" } */
+  printf ("% n", n); /* { dg-warning "flag" "bad use of space flag" } */
+  /* Uses of the # flag.  */
+  printf ("%#o%#x%#X%#e%#E%#f%#F%#g%#G%#a%#A", u, u, u, d, d, d, d,
+         d, d, d, d);
+  printf ("%#d", i); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#i", i); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#u", u); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#c", i); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#s", s); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#p", p); /* { dg-warning "flag" "bad use of # flag" } */
+  printf ("%#n", n); /* { dg-warning "flag" "bad use of # flag" } */
+  /* Uses of the 0 flag.  */
+  printf ("%08d%08i%08o%08u%08x%08X%08e%08E%08f%08F%08g%08G%08a%08A", i, i,
+         u, u, u, u, d, d, d, d, d, d, d, d);
+  printf ("%0c", i); /* { dg-warning "flag" "bad use of 0 flag" } */
+  printf ("%0s", s); /* { dg-warning "flag" "bad use of 0 flag" } */
+  printf ("%0p", p); /* { dg-warning "flag" "bad use of 0 flag" } */
+  printf ("%0n", n); /* { dg-warning "flag" "bad use of 0 flag" } */
+  /* 0 flag ignored with precision for certain types, not others.  */
+  printf ("%08.5d", i); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5i", i); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5o", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5u", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5x", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5X", u); /* { dg-warning "ignored" "0 flag ignored with precision" } */
+  printf ("%08.5f%08.5F%08.5e%08.5E%08.5g%08.5G%08.5a%08.5A",
+         d, d, d, d, d, d, d, d);
+  /* 0 flag ignored with - flag.  */
+  printf ("%-08d", i); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08i", i); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08o", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08u", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08x", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08X", u); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08e", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08E", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08f", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08F", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08g", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08G", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08a", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  printf ("%-08A", d); /* { dg-warning "flags|ignored" "0 flag ignored with - flag" } */
+  /* Various tests of bad argument types.  Mostly covered in c90-printf-1.c;
+     here just test for pointer target sign with %hhn.  (Probably allowed
+     by the standard, but a bad idea, so GCC should diagnose if what
+     is used is not signed char *.)
+  */
+  printf ("%hhn", s); /* { dg-warning "format" "%hhn plain char" } */
+  printf ("%hhn", us); /* { dg-warning "format" "%hhn unsigned char" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c99-printf-2.c b/gcc/testsuite/gcc.dg/format/c99-printf-2.c
new file mode 100644 (file)
index 0000000..26b9de9
--- /dev/null
@@ -0,0 +1,36 @@
+/* Test for printf formats.  Formats using extensions to the standard
+   should be rejected in strict pedantic mode.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+typedef __WCHAR_TYPE__ wchar_t;
+typedef __WINT_TYPE__ wint_t;
+
+extern int printf (const char *, ...);
+
+void
+foo (int i, long long ll, size_t z, wint_t lc, wchar_t *ls)
+{
+  /* The length modifiers q, Z and L as applied to integer formats are
+     extensions.
+  */
+  printf ("%qd", ll); /* { dg-warning "C" "%q length" } */
+  printf ("%Ld", ll); /* { dg-warning "C" "%L length" } */
+  printf ("%Zd", z); /* { dg-warning "C" "%Z length" } */
+  /* The conversion specifiers C and S are X/Open extensions; the
+     conversion specifier m is a GNU extension.
+  */
+  printf ("%m"); /* { dg-warning "C" "printf %m" } */
+  printf ("%C", lc); /* { dg-warning "C" "printf %C" } */
+  printf ("%S", ls); /* { dg-warning "C" "printf %S" } */
+  /* The flag character ', and the use of operand number $ formats, are
+     X/Open extensions.
+  */
+  printf ("%'d", i); /* { dg-warning "C" "printf ' flag" } */
+  printf ("%1$d", i); /* { dg-warning "C" "printf $ format" } */
+  /* The flag character I is a GNU extension.  */
+  printf ("%Id", i); /* { dg-warning "C" "printf I flag" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c99-printf-3.c b/gcc/testsuite/gcc.dg/format/c99-printf-3.c
new file mode 100644 (file)
index 0000000..26f76d7
--- /dev/null
@@ -0,0 +1,56 @@
+/* Test for printf formats.  Test that the C99 functions get their default
+   attributes in strict C99 mode, but the gettext functions do not.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
+
+/* This may not be correct in the particular case, but allows the
+   prototypes to be declared, and we don't try to link.
+*/
+typedef struct _FILE FILE;
+extern FILE *stdout;
+
+typedef __SIZE_TYPE__ size_t;
+typedef __builtin_va_list va_list;
+
+extern int fprintf (FILE *restrict, const char *restrict, ...);
+extern int printf (const char *restrict, ...);
+extern int sprintf (char *restrict, const char *restrict, ...);
+extern int vfprintf (FILE *restrict, const char *restrict, va_list);
+extern int vprintf (const char *restrict, va_list);
+extern int vsprintf (char *restrict, const char *restrict, va_list);
+extern int snprintf (char *restrict, size_t, const char *restrict, ...);
+extern int vsnprintf (char *restrict, size_t, const char *restrict, va_list);
+
+extern char *gettext (const char *);
+extern char *dgettext (const char *, const char *);
+extern char *dcgettext (const char *, const char *, int);
+
+void
+foo (int i, char *s, size_t n, va_list v0, va_list v1, va_list v2, va_list v3,
+     va_list v4, va_list v5, va_list v6, va_list v7)
+{
+  fprintf (stdout, "%d", i);
+  fprintf (stdout, "%ld", i); /* { dg-warning "format" "fprintf" } */
+  printf ("%d", i);
+  printf ("%ld", i); /* { dg-warning "format" "printf" } */
+  sprintf (s, "%d", i);
+  sprintf (s, "%ld", i); /* { dg-warning "format" "sprintf" } */
+  snprintf (s, n, "%d", i);
+  snprintf (s, n, "%ld", i); /* { dg-warning "format" "snprintf" } */
+  vfprintf (stdout, "%d", v0);
+  vfprintf (stdout, "%Y", v1); /* { dg-warning "format" "vfprintf" } */
+  vprintf ("%d", v0);
+  vprintf ("%Y", v1); /* { dg-warning "format" "vprintf" } */
+  vsprintf (s, "%d", v0);
+  vsprintf (s, "%Y", v1); /* { dg-warning "format" "vsprintf" } */
+  vsnprintf (s, n, "%d", v0);
+  vsnprintf (s, n, "%Y", v1); /* { dg-warning "format" "vsnprintf" } */
+  printf (gettext ("%d"), i);
+  printf (gettext ("%ld"), i);
+  printf (dgettext ("", "%d"), i);
+  printf (dgettext ("", "%ld"), i);
+  printf (dcgettext ("", "%d", 0), i);
+  printf (dcgettext ("", "%ld", 0), i);
+}
diff --git a/gcc/testsuite/gcc.dg/format/c99-scanf-1.c b/gcc/testsuite/gcc.dg/format/c99-scanf-1.c
new file mode 100644 (file)
index 0000000..369f02e
--- /dev/null
@@ -0,0 +1,176 @@
+/* Test for scanf formats.  Formats using C99 features, including cases
+   where C99 specifies some aspect of the format to be ignored or where
+   the behaviour is undefined.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+
+/* Kludges to get types corresponding to size_t and ptrdiff_t.  */
+#define unsigned signed
+typedef __SIZE_TYPE__ signed_size_t;
+#undef unsigned
+#define signed /* Type might or might not have explicit 'signed'.  */
+typedef unsigned __PTRDIFF_TYPE__ unsigned_ptrdiff_t;
+#undef signed
+
+/* These next definitions are kludges.  When GCC has a <stdint.h> it
+   should be used.
+*/
+#include <limits.h>
+#if INT_MAX == LLONG_MAX
+typedef int intmax_t;
+#elif LONG_MAX == LLONG_MAX
+typedef long intmax_t;
+#else
+typedef long long intmax_t;
+#endif
+#if UINT_MAX == ULLONG_MAX
+typedef unsigned int uintmax_t;
+#elif ULONG_MAX == ULLONG_MAX
+typedef unsigned long uintmax_t;
+#else
+typedef unsigned long long uintmax_t;
+#endif
+
+extern int scanf (const char *, ...);
+
+void
+foo (int *ip, unsigned int *uip, short int *hp, unsigned short int *uhp,
+     signed char *hhp, unsigned char *uhhp, long int *lp,
+     unsigned long int *ulp, float *fp, double *dp, long double *ldp, char *s,
+     void **pp, int *n, long long *llp, unsigned long long *ullp, wchar_t *ls,
+     short int *hn, signed char *hhn, long int *ln, long long int *lln,
+     intmax_t *jp, uintmax_t *ujp, intmax_t *jn, size_t *zp,
+     signed_size_t *szp, signed_size_t *zn, ptrdiff_t *tp,
+     unsigned_ptrdiff_t *utp, ptrdiff_t *tn)
+{
+  /* See ISO/IEC 9899:1999 (E) subclause 7.19.6.2 (pages 281-288).
+     We do not repeat here most of the checks for correct C90 formats
+     or completely broken formats.
+  */
+  /* Valid, invalid and silly assignment-suppression
+     and width constructions.
+  */
+  scanf ("%*d%*i%*o%*u%*x%*X%*a%*A%*e%*E%*f%*F%*g%*G%*s%*[abc]%*c%*p");
+  scanf ("%*2d%*8s%*3c");
+  scanf ("%*n", n); /* { dg-warning "suppress" "suppression of %n" } */
+  scanf ("%*hd"); /* { dg-warning "together" "suppression with length" } */
+  scanf ("%2d%3i%4o%5u%6x%7X%8a%9A%10e%11E%12f%13F%14g%15G%16s%3[abc]%4c%5p",
+        ip, ip, uip, uip, uip, uip, fp, fp, fp, fp, fp, fp, fp, fp,
+        s, s, s, pp);
+  scanf ("%0d", ip); /* { dg-warning "width" "warning for zero width" } */
+  scanf ("%3n", n); /* { dg-warning "width" "width with %n" } */
+  /* Valid and invalid %h, %hh, %l, %ll, %j, %z, %t, %L constructions.  */
+  scanf ("%hd%hi%ho%hu%hx%hX%hn", hp, hp, uhp, uhp, uhp, uhp, hn);
+  scanf ("%ha", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hA", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%he", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hE", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hf", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hF", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hg", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hG", fp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hs", s); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%h[ac]", s); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hc", s); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hp", pp); /* { dg-warning "length" "bad use of %h" } */
+  scanf ("%hhd%hhi%hho%hhu%hhx%hhX%hhn", hhp, hhp, uhhp, uhhp, uhhp, uhhp,
+        hhn);
+  scanf ("%hha", fp); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%hhA", fp); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%hhe", fp); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%hhE", fp); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%hhf", fp); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%hhF", fp); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%hhg", fp); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%hhG", fp); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%hhs", s); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%hh[ac]", s); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%hhc", s); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%hhp", pp); /* { dg-warning "length" "bad use of %hh" } */
+  scanf ("%ld%li%lo%lu%lx%lX%ln", lp, lp, ulp, ulp, ulp, ulp, ln);
+  scanf ("%la%lA%le%lE%lf%lF%lg%lG", dp, dp, dp, dp, dp, dp, dp, dp);
+  scanf ("%lp", pp); /* { dg-warning "length" "bad use of %l" } */
+  scanf ("%ls", ls);
+  scanf ("%l[ac]", ls);
+  scanf ("%lc", ls);
+  scanf ("%lld%lli%llo%llu%llx%llX%lln", llp, llp, ullp, ullp, ullp, ullp,
+        lln);
+  scanf ("%lla", fp); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%llA", fp); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%lle", fp); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%llE", fp); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%llf", fp); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%llF", fp); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%llg", fp); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%llG", fp); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%lls", s); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%ll[ac]", s); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%llc", s); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%llp", pp); /* { dg-warning "length" "bad use of %ll" } */
+  scanf ("%jd%ji%jo%ju%jx%jX%jn", jp, jp, ujp, ujp, ujp, ujp, jn); /* { dg-bogus "length" "bogus %j warning" { target *-*-* } } */
+  scanf ("%ja", fp); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%jA", fp); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%je", fp); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%jE", fp); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%jf", fp); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%jF", fp); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%jg", fp); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%jG", fp); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%js", s); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%j[ac]", s); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%jc", s); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%jp", pp); /* { dg-warning "length" "bad use of %j" } */
+  scanf ("%zd%zi%zo%zu%zx%zX%zn", szp, szp, zp, zp, zp, zp, zn);
+  scanf ("%za", fp); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%zA", fp); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%ze", fp); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%zE", fp); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%zf", fp); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%zF", fp); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%zg", fp); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%zG", fp); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%zs", s); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%z[ac]", s); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%zc", s); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%zp", pp); /* { dg-warning "length" "bad use of %z" } */
+  scanf ("%td%ti%to%tu%tx%tX%tn", tp, tp, utp, utp, utp, utp, tn);
+  scanf ("%ta", fp); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%tA", fp); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%te", fp); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%tE", fp); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%tf", fp); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%tF", fp); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%tg", fp); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%tG", fp); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%ts", s); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%t[ac]", s); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%tc", s); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%tp", pp); /* { dg-warning "length" "bad use of %t" } */
+  scanf ("%La%LA%Le%LE%Lf%LF%Lg%LG", ldp, ldp, ldp, ldp, ldp, ldp, ldp, ldp);
+  scanf ("%Ld", llp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%Li", llp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%Lo", ullp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%Lu", ullp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%Lx", ullp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%LX", ullp); /* { dg-warning "does not support" "bad use of %L" } */
+  scanf ("%Ls", s); /* { dg-warning "length" "bad use of %L" } */
+  scanf ("%L[ac]", s); /* { dg-warning "length" "bad use of %L" } */
+  scanf ("%Lc", s); /* { dg-warning "length" "bad use of %L" } */
+  scanf ("%Lp", pp); /* { dg-warning "length" "bad use of %L" } */
+  scanf ("%Ln", n); /* { dg-warning "length" "bad use of %L" } */
+  /* Valid uses of each bare conversion.  */
+  scanf ("%d%i%o%u%x%X%a%A%e%E%f%F%g%G%s%[abc]%c%p%n%%", ip, ip, uip, uip, uip,
+         uip, fp, fp, fp, fp, fp, fp, fp, fp, s, s, s, pp, n);
+  /* Assert that %as is not treated as an extension in C99 mode.  */
+  scanf ("%as", fp);
+  scanf ("%a[", fp);
+  /* Tests for bad argument types: pointer target sign with %hh.  */
+  scanf ("%hhd", uhhp); /* { dg-warning "format" "%hhd sign" } */
+  scanf ("%hhu", hhp); /* { dg-warning "format" "%hhu sign" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c99-scanf-2.c b/gcc/testsuite/gcc.dg/format/c99-scanf-2.c
new file mode 100644 (file)
index 0000000..a740a60
--- /dev/null
@@ -0,0 +1,28 @@
+/* Test for scanf formats.  Formats using extensions to the standard
+   should be rejected in strict pedantic mode.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+extern int scanf (const char *, ...);
+
+void
+foo (int *ip, long long int *llp, wchar_t *ls)
+{
+  /* The length modifiers q and L as applied to integer formats are
+     extensions.
+  */
+  scanf ("%qd", llp); /* { dg-warning "C" "%q length" } */
+  scanf ("%Ld", llp); /* { dg-warning "C" "%L length" } */
+  /* The conversion specifiers C and S are X/Open extensions.  */
+  scanf ("%C", ls); /* { dg-warning "C" "scanf %C" } */
+  scanf ("%S", ls); /* { dg-warning "C" "scanf %S" } */
+  /* The use of operand number $ formats is an X/Open extension.  */
+  scanf ("%1$d", ip); /* { dg-warning "C" "scanf $ format" } */
+  /* glibc also supports flags ' and I on scanf formats as an extension.  */
+  scanf ("%'d", ip); /* { dg-warning "C" "scanf ' flag" } */
+  scanf ("%Id", ip); /* { dg-warning "C" "scanf I flag" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c99-scanf-3.c b/gcc/testsuite/gcc.dg/format/c99-scanf-3.c
new file mode 100644 (file)
index 0000000..df30c05
--- /dev/null
@@ -0,0 +1,49 @@
+/* Test for scanf formats.  Test that the C99 functions get their default
+   attributes in strict C99 mode, but the gettext functions do not.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
+
+/* This may not be correct in the particular case, but allows the
+   prototypes to be declared, and we don't try to link.
+*/
+typedef struct _FILE FILE;
+extern FILE *stdin;
+
+typedef __builtin_va_list va_list;
+
+extern int fscanf (FILE *restrict, const char *restrict, ...);
+extern int scanf (const char *restrict, ...);
+extern int sscanf (const char *restrict, const char *restrict, ...);
+extern int vfscanf (FILE *restrict, const char *restrict, va_list);
+extern int vscanf (const char *restrict, va_list);
+extern int vsscanf (const char *restrict, const char *restrict, va_list);
+
+extern char *gettext (const char *);
+extern char *dgettext (const char *, const char *);
+extern char *dcgettext (const char *, const char *, int);
+
+void
+foo (int *ip, char *s, va_list v0, va_list v1, va_list v2, va_list v3,
+     va_list v4, va_list v5)
+{
+  fscanf (stdin, "%d", ip);
+  fscanf (stdin, "%ld", ip); /* { dg-warning "format" "fscanf" } */
+  scanf ("%d", ip);
+  scanf ("%ld", ip); /* { dg-warning "format" "scanf" } */
+  sscanf (s, "%d", ip);
+  sscanf (s, "%ld", ip); /* { dg-warning "format" "sscanf" } */
+  vfscanf (stdin, "%d", v0);
+  vfscanf (stdin, "%Y", v1); /* { dg-warning "format" "vfscanf" } */
+  vscanf ("%d", v2);
+  vscanf ("%Y", v3); /* { dg-warning "format" "vscanf" } */
+  vsscanf (s, "%d", v4);
+  vsscanf (s, "%Y", v5); /* { dg-warning "format" "vsscanf" } */
+  scanf (gettext ("%d"), ip);
+  scanf (gettext ("%ld"), ip);
+  scanf (dgettext ("", "%d"), ip);
+  scanf (dgettext ("", "%ld"), ip);
+  scanf (dcgettext ("", "%d", 0), ip);
+  scanf (dcgettext ("", "%ld", 0), ip);
+}
diff --git a/gcc/testsuite/gcc.dg/format/c99-strftime-1.c b/gcc/testsuite/gcc.dg/format/c99-strftime-1.c
new file mode 100644 (file)
index 0000000..187fc7c
--- /dev/null
@@ -0,0 +1,101 @@
+/* Test for strftime formats.  Formats using C99 features.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+struct tm;
+
+extern size_t strftime (char *, size_t, const char *, const struct tm *);
+
+void
+foo (char *s, size_t m, const struct tm *tp)
+{
+  /* See ISO/IEC 9899:1990 (E) subclause 7.12.3.5 (pages 174-175).  */
+  /* Formats which are Y2K-compliant (no 2-digit years).  */
+  strftime (s, m, "%a%A%b%B%C%d%e%F%G%h%H%I%j%m%M%p%R%S%t%T%u%U%V%w%W%X%Y%z%Z%%", tp);
+  strftime (s, m, "%EC%EX%EY%Od%Oe%OH%OI%Om%OM%OS%Ou%OU%OV%Ow%OW", tp);
+  /* Formats with 2-digit years.  */
+  strftime (s, m, "%D", tp); /* { dg-warning "only last 2" "2-digit year" } */
+  strftime (s, m, "%g", tp); /* { dg-warning "only last 2" "2-digit year" } */
+  strftime (s, m, "%y", tp); /* { dg-warning "only last 2" "2-digit year" } */
+  strftime (s, m, "%Oy", tp); /* { dg-warning "only last 2" "2-digit year" } */
+  /* Formats with 2-digit years in some locales.  */
+  strftime (s, m, "%c", tp); /* { dg-warning "some locales" "2-digit year" } */
+  strftime (s, m, "%Ec", tp); /* { dg-warning "some locales" "2-digit year" } */
+  strftime (s, m, "%x", tp); /* { dg-warning "some locales" "2-digit year" } */
+  strftime (s, m, "%Ex", tp); /* { dg-warning "some locales" "2-digit year" } */
+  /* %Ey is explicitly an era offset not a 2-digit year; but in some
+     locales the E modifier may be ignored.
+  */
+  strftime (s, m, "%Ey", tp); /* { dg-warning "some locales" "2-digit year" } */
+  /* Bad uses of %E and %O.  */
+  strftime (s, m, "%EEY", tp); /* { dg-warning "multiple|repeated" "multiple %E/%O" } */
+  strftime (s, m, "%EOy", tp); /* { dg-warning "multiple|together" "multiple %E/%O" } */
+  strftime (s, m, "%OEy", tp); /* { dg-warning "multiple|together" "multiple %E/%O" } */
+  strftime (s, m, "%OOV", tp); /* { dg-warning "multiple|repeated" "multiple %E/%O" } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 35 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 36 } */
+  strftime (s, m, "%Ea", tp); /* { dg-warning "flag|modifier" "bad %Ea" } */
+  strftime (s, m, "%EA", tp); /* { dg-warning "flag|modifier" "bad %EA" } */
+  strftime (s, m, "%Eb", tp); /* { dg-warning "flag|modifier" "bad %Eb" } */
+  strftime (s, m, "%EB", tp); /* { dg-warning "flag|modifier" "bad %EB" } */
+  strftime (s, m, "%Ed", tp); /* { dg-warning "flag|modifier" "bad %Ed" } */
+  strftime (s, m, "%ED", tp); /* { dg-warning "flag|modifier" "bad %ED" } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 45 } */
+  strftime (s, m, "%Ee", tp); /* { dg-warning "flag|modifier" "bad %Ee" } */
+  strftime (s, m, "%EF", tp); /* { dg-warning "flag|modifier" "bad %EF" } */
+  strftime (s, m, "%Eg", tp); /* { dg-warning "flag|modifier" "bad %Eg" } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 49 } */
+  strftime (s, m, "%EG", tp); /* { dg-warning "flag|modifier" "bad %EG" } */
+  strftime (s, m, "%Eh", tp); /* { dg-warning "flag|modifier" "bad %Eh" } */
+  strftime (s, m, "%EH", tp); /* { dg-warning "flag|modifier" "bad %EH" } */
+  strftime (s, m, "%EI", tp); /* { dg-warning "flag|modifier" "bad %EI" } */
+  strftime (s, m, "%Ej", tp); /* { dg-warning "flag|modifier" "bad %Ej" } */
+  strftime (s, m, "%Em", tp); /* { dg-warning "flag|modifier" "bad %Em" } */
+  strftime (s, m, "%EM", tp); /* { dg-warning "flag|modifier" "bad %EM" } */
+  strftime (s, m, "%En", tp); /* { dg-warning "flag|modifier" "bad %En" } */
+  strftime (s, m, "%Ep", tp); /* { dg-warning "flag|modifier" "bad %Ep" } */
+  strftime (s, m, "%Er", tp); /* { dg-warning "flag|modifier" "bad %Er" } */
+  strftime (s, m, "%ER", tp); /* { dg-warning "flag|modifier" "bad %ER" } */
+  strftime (s, m, "%ES", tp); /* { dg-warning "flag|modifier" "bad %ES" } */
+  strftime (s, m, "%Et", tp); /* { dg-warning "flag|modifier" "bad %Et" } */
+  strftime (s, m, "%ET", tp); /* { dg-warning "flag|modifier" "bad %ET" } */
+  strftime (s, m, "%Eu", tp); /* { dg-warning "flag|modifier" "bad %Eu" } */
+  strftime (s, m, "%EU", tp); /* { dg-warning "flag|modifier" "bad %EU" } */
+  strftime (s, m, "%EV", tp); /* { dg-warning "flag|modifier" "bad %EV" } */
+  strftime (s, m, "%Ew", tp); /* { dg-warning "flag|modifier" "bad %Ew" } */
+  strftime (s, m, "%EW", tp); /* { dg-warning "flag|modifier" "bad %EW" } */
+  strftime (s, m, "%Ez", tp); /* { dg-warning "flag|modifier" "bad %Ez" } */
+  strftime (s, m, "%EZ", tp); /* { dg-warning "flag|modifier" "bad %EZ" } */
+  strftime (s, m, "%E%", tp); /* { dg-warning "flag|modifier" "bad %E%" } */
+  strftime (s, m, "%Oa", tp); /* { dg-warning "flag|modifier" "bad %Oa" } */
+  strftime (s, m, "%OA", tp); /* { dg-warning "flag|modifier" "bad %OA" } */
+  strftime (s, m, "%Ob", tp); /* { dg-warning "flag|modifier" "bad %Ob" } */
+  strftime (s, m, "%OB", tp); /* { dg-warning "flag|modifier" "bad %OB" } */
+  strftime (s, m, "%Oc", tp); /* { dg-warning "flag|modifier" "bad %Oc" } */
+  /* { dg-warning "in some locales" "2-digit year" { target *-*-* } 77 } */
+  strftime (s, m, "%OC", tp); /* { dg-warning "flag|modifier|C" "bad %OC" } */
+  strftime (s, m, "%OD", tp); /* { dg-warning "flag|modifier" "bad %OD" } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 80 } */
+  strftime (s, m, "%OF", tp); /* { dg-warning "flag|modifier" "bad %OF" } */
+  strftime (s, m, "%Og", tp); /* { dg-warning "flag|modifier|C" "bad %Og" } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 83 } */
+  strftime (s, m, "%OG", tp); /* { dg-warning "flag|modifier|C" "bad %OG" } */
+  strftime (s, m, "%Oh", tp); /* { dg-warning "flag|modifier" "bad %Oh" } */
+  strftime (s, m, "%Oj", tp); /* { dg-warning "flag|modifier|C" "bad %Oj" } */
+  strftime (s, m, "%On", tp); /* { dg-warning "flag|modifier" "bad %On" } */
+  strftime (s, m, "%Op", tp); /* { dg-warning "flag|modifier" "bad %Op" } */
+  strftime (s, m, "%Or", tp); /* { dg-warning "flag|modifier" "bad %Or" } */
+  strftime (s, m, "%OR", tp); /* { dg-warning "flag|modifier" "bad %OR" } */
+  strftime (s, m, "%Ot", tp); /* { dg-warning "flag|modifier" "bad %Ot" } */
+  strftime (s, m, "%OT", tp); /* { dg-warning "flag|modifier" "bad %OT" } */
+  strftime (s, m, "%Ox", tp); /* { dg-warning "flag|modifier" "bad %Ox" } */
+  /* { dg-warning "in some locales" "2-digit year" { target *-*-* } 94 } */
+  strftime (s, m, "%OX", tp); /* { dg-warning "flag|modifier" "bad %OX" } */
+  strftime (s, m, "%OY", tp); /* { dg-warning "flag|modifier|C" "bad %OY" } */
+  strftime (s, m, "%Oz", tp); /* { dg-warning "flag|modifier|C" "bad %Oz" } */
+  strftime (s, m, "%OZ", tp); /* { dg-warning "flag|modifier" "bad %OZ" } */
+  strftime (s, m, "%O%", tp); /* { dg-warning "flag|modifier" "bad %O%" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/c99-strftime-2.c b/gcc/testsuite/gcc.dg/format/c99-strftime-2.c
new file mode 100644 (file)
index 0000000..45d8ef4
--- /dev/null
@@ -0,0 +1,27 @@
+/* Test for strftime formats.  Rejection of extensions in pedantic mode.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+struct tm;
+
+extern size_t strftime (char *, size_t, const char *, const struct tm *);
+
+void
+foo (char *s, size_t m, const struct tm *tp)
+{
+  /* %P is a lowercase version of %p.  */
+  strftime (s, m, "%P", tp); /* { dg-warning "C" "strftime %P" } */
+  /* %k is %H but padded with a space rather than 0 if necessary.  */
+  strftime (s, m, "%k", tp); /* { dg-warning "C" "strftime %k" } */
+  /* %l is %I but padded with a space rather than 0 if necessary.  */
+  strftime (s, m, "%l", tp); /* { dg-warning "C" "strftime %l" } */
+  /* %s is the number of seconds since the Epoch.  */
+  strftime (s, m, "%s", tp); /* { dg-warning "C" "strftime %s" } */
+  /* Extensions using %O already tested in c99-strftime-1.c.  */
+  /* Width and flags are GNU extensions for strftime.  */
+  strftime (s, m, "%20Y", tp); /* { dg-warning "C" "strftime width" } */
+  strftime (s, m, "%^A", tp); /* { dg-warning "C" "strftime flags" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/diag-1.c b/gcc/testsuite/gcc.dg/format/diag-1.c
new file mode 100644 (file)
index 0000000..33364d7
--- /dev/null
@@ -0,0 +1,18 @@
+/* Test for format diagnostics.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat" } */
+
+extern int printf (const char *, ...);
+
+void
+foo (double d)
+{
+  /* This should get a message referring to `hh', not to `H'.  */
+  printf ("%hhf", d); /* { dg-warning "hh" "%hhf warning" } */
+  /* This should get a message referring to `ll', not to `q'.  */
+  printf ("%llf", d); /* { dg-warning "ll" "%llf warning" } */
+  /* This should get a message referring to `size_t format', not to
+     `unsigned int format' or similar.  */
+  printf ("%zu", d); /* { dg-warning "size_t format" "size_t format warning" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/errmk-1.c b/gcc/testsuite/gcc.dg/format/errmk-1.c
new file mode 100644 (file)
index 0000000..bf05f4e
--- /dev/null
@@ -0,0 +1,12 @@
+/* Test for format checking not giving tree checking errors.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-Wformat" } */
+
+extern int printf (const char *, ...);
+
+void
+foo (int t)
+{
+  printf ("%*d", u, t); /* { dg-error "undeclared|function" "u undeclared error" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/ext-1.c b/gcc/testsuite/gcc.dg/format/ext-1.c
new file mode 100644 (file)
index 0000000..238a478
--- /dev/null
@@ -0,0 +1,127 @@
+/* Test for format extensions beyond the C standard and X/Open standard.
+   Test for printf formats.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat" } */
+
+/* %q formats want a "quad"; GCC considers this to be a long long.  */
+typedef long long int quad_t;
+typedef unsigned long long int u_quad_t;
+
+typedef __WCHAR_TYPE__ wchar_t;
+typedef __WINT_TYPE__ wint_t;
+typedef __SIZE_TYPE__ size_t;
+
+extern int printf (const char *, ...);
+
+void
+foo (quad_t q, u_quad_t uq, quad_t *qn, size_t z, size_t *zn, long long int ll,
+     unsigned long long int ull, int i, unsigned int u, double d,
+     char *s, void *p, wchar_t *ls, wint_t lc, int *n, long int l)
+{
+  /* As an extension, GCC allows the BSD length "q" for integer formats.
+     This is largely obsoleted in C99 by %j, %ll and PRId64.
+  */
+  printf ("%qd%qi%qo%qu%qx%qX%qn", q, q, uq, uq, uq, uq, qn);
+  printf ("%qf", d); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qF", d); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qe", d); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qE", d); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qg", d); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qG", d); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qa", d); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qA", d); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qc", i); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qs", s); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qp", p); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qC", lc); /* { dg-warning "length" "bad use of %q" } */
+  printf ("%qS", ls); /* { dg-warning "length" "bad use of %q" } */
+  /* With a bad length GCC wants some argument, any argument,
+     to devour with the format conversion, as a synchronisation heuristic.
+     This may get improved later.
+  */
+  printf ("%qm", i); /* { dg-warning "length" "bad use of %q" } */
+  /* As an extension, GCC allows the length "Z" as a synonym for "z".
+     This was an extension predating C99 which should now be considered
+     deprecated; use the standard "z" instead.
+  */
+  printf ("%Zd%Zi%Zo%Zu%Zx%ZX", z, z, z, z, z, z);
+  printf ("%Zn", zn);
+  printf ("%Zf", d); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%ZF", d); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%Ze", d); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%ZE", d); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%Zg", d); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%ZG", d); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%Za", d); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%ZA", d); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%Zc", i); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%Zs", s); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%Zp", p); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%ZC", lc); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%ZS", ls); /* { dg-warning "length" "bad use of %Z" } */
+  printf ("%Zm", i); /* { dg-warning "length" "bad use of %Z" } */
+  /* As an extension, GCC allows the length "L" on integer formats
+     (but not %n) as a synonym for "ll".
+     This should be considered deprecated.
+  */
+  printf ("%Ld%Li%Lo%Lu%Lx%LX", ll, ll, ull, ull, ull, ull);
+  /* As an extension, derived from syslog, GCC allows the conversion
+     specifier "m" for formatting strerror(errno).  This may be used
+     with width, precision and the "-" flag, the same as %s.
+  */
+  printf ("%m%3m%.4m%5.6m");
+  printf ("%*m", i);
+  printf ("%.*m", i);
+  printf ("%*.*m", i, i);
+  printf ("%3.*m", i);
+  printf ("%*.4m", i);
+  printf ("%-m");
+  printf ("%+m"); /* { dg-warning "flag" "bad %+m" } */
+  printf ("% m"); /* { dg-warning "flag" "bad % m" } */
+  printf ("%#m"); /* { dg-warning "flag" "bad %#m" } */
+  printf ("%0m"); /* { dg-warning "flag" "bad %0m" } */
+  printf ("%'m"); /* { dg-warning "flag" "bad %'m" } */
+  printf ("%hm", i); /* { dg-warning "length" "bad %hm" } */
+  printf ("%hhm", i); /* { dg-warning "length" "bad %hhm" } */
+  printf ("%lm", i); /* { dg-warning "length" "bad %lm" } */
+  printf ("%llm", i); /* { dg-warning "length" "bad %llm" } */
+  printf ("%jm", i); /* { dg-warning "length" "bad %jm" } */
+  printf ("%zm", i); /* { dg-warning "length" "bad %zm" } */
+  printf ("%tm", i); /* { dg-warning "length" "bad %tm" } */
+  printf ("%Lm", i); /* { dg-warning "length" "bad %Lm" } */
+  printf ("%qm", i); /* { dg-warning "length" "bad %qm" } */
+  printf ("%Zm", i); /* { dg-warning "length" "bad %Zm" } */
+  /* It should be OK to mix %m formats with $ operand number formats.  */
+  printf ("%2$ld%m%1$d", i, l);
+  /* Likewise, %m formats with width and precision should not have an
+     operand number for the %m itself.
+  */
+  printf ("%*2$.*1$m", i, i);
+  printf ("%1$*2$.*1$m", i, i); /* { dg-warning "no argument" "printf %1\$m" } */
+  /* As an extension, glibc includes the "I" flag for decimal integer
+     formats, to output using the locale's digits (e.g. in Arabic).
+     In GCC, we require this to be in the standard place for flags, though
+     glibc allows it also after width or precision.
+  */
+  printf ("%Id%Ii%Iu", i, i, u);
+  printf ("%Io", u); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%Ix", u); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%IX", u); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%In", n); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%If", d); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%IF", d); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%Ie", d); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%IE", d); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%Ig", d); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%IG", d); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%Ia", d); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%IA", d); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%Ic", i); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%Is", s); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%Ip", p); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%IC", lc); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%IS", ls); /* { dg-warning "flag" "bad use of I flag" } */
+  printf ("%Im"); /* { dg-warning "flag" "bad use of I flag" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/ext-2.c b/gcc/testsuite/gcc.dg/format/ext-2.c
new file mode 100644 (file)
index 0000000..68c1b03
--- /dev/null
@@ -0,0 +1,79 @@
+/* Test for format extensions beyond the C standard and X/Open standard.
+   Test for scanf formats.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat" } */
+
+/* %q formats want a "quad"; GCC considers this to be a long long.  */
+typedef long long int quad_t;
+typedef unsigned long long int u_quad_t;
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+extern int scanf (const char *, ...);
+
+void
+foo (quad_t *qp, u_quad_t *uqp, quad_t *qn, long long int *llp,
+     unsigned long long int *ullp, float *fp, char *s, void **pp, wchar_t *ls,
+     int *ip, unsigned int *up)
+{
+  /* As an extension, GCC allows the BSD length "q" for integer formats.
+     This is largely obsoleted in C99 by %j, %ll and SCNd64.
+  */
+  scanf ("%qd%qi%qo%qu%qx%qX%qn", qp, qp, uqp, uqp, uqp, uqp, qn);
+  scanf ("%qf", fp); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qF", fp); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qe", fp); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qE", fp); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qg", fp); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qG", fp); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qa", fp); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qA", fp); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qs", s); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%q[abc]", s); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qc", s); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qp", pp); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qC", ls); /* { dg-warning "length" "bad use of %q" } */
+  scanf ("%qS", ls); /* { dg-warning "length" "bad use of %q" } */
+  /* As an extension, GCC allows the length "L" on integer formats
+     (but not %n) as a synonym for "ll".
+     This should be considered deprecated.
+  */
+  scanf ("%Ld%Li%Lo%Lu%Lx%LX", llp, llp, ullp, ullp, ullp, ullp);
+  /* glibc also supports flags ' and I on scanf formats.  The ' flag applies
+     to all formats scanning decimal values; the I flag only to decimal integer
+     formats.
+  */
+  scanf ("%'d%'i%'u%'a%'A%'e%'E%'f%'F%'g%'G", ip, ip, up, fp, fp, fp, fp,
+        fp, fp, fp, fp);
+  scanf ("%'o", up); /* { dg-warning "flag" "bad use of ' flag" } */
+  scanf ("%'x", up); /* { dg-warning "flag" "bad use of ' flag" } */
+  scanf ("%'X", up); /* { dg-warning "flag" "bad use of ' flag" } */
+  scanf ("%'n", ip); /* { dg-warning "flag" "bad use of ' flag" } */
+  scanf ("%'s", s); /* { dg-warning "flag" "bad use of ' flag" } */
+  scanf ("%'[abc]", s); /* { dg-warning "flag" "bad use of ' flag" } */
+  scanf ("%'c", s); /* { dg-warning "flag" "bad use of ' flag" } */
+  scanf ("%'p", pp); /* { dg-warning "flag" "bad use of ' flag" } */
+  scanf ("%'C", ls); /* { dg-warning "flag" "bad use of ' flag" } */
+  scanf ("%'S", ls); /* { dg-warning "flag" "bad use of ' flag" } */
+  scanf ("%Id%Ii%Iu", ip, ip, up);
+  scanf ("%Ia", fp); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%IA", fp); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%Ie", fp); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%IE", fp); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%If", fp); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%IF", fp); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%Ig", fp); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%IG", fp); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%Io", up); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%Ix", up); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%IX", up); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%In", ip); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%Is", s); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%I[abc]", s); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%Ic", s); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%Ip", pp); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%IC", ls); /* { dg-warning "flag" "bad use of I flag" } */
+  scanf ("%IS", ls); /* { dg-warning "flag" "bad use of I flag" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/ext-3.c b/gcc/testsuite/gcc.dg/format/ext-3.c
new file mode 100644 (file)
index 0000000..ea9f2e0
--- /dev/null
@@ -0,0 +1,220 @@
+/* Test for format extensions beyond the C standard and X/Open standard.
+   Test for strftime formats.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+struct tm;
+
+extern size_t strftime (char *, size_t, const char *, const struct tm *);
+
+void
+foo (char *s, size_t m, const struct tm *tp)
+{
+  /* GCC accepts the "-", "_" and "0" flags to control padding on numeric
+     formats.  It also accepts width on these formats.
+  */
+  /* Basic tests of parts on their own.  */
+  strftime (s, m, "%5C%-C%_C%0C", tp);
+  /* Correct usages.  */
+  strftime (s, m, "%-5C%_5C%05C%-5d%_5d%05d%-5e%_5e%05e%-5G%_5G%05G", tp);
+  strftime (s, m, "%-5H%_5H%05H%-5I%_5I%05I%-5j%_5j%05j%-5m%_5m%05m", tp);
+  strftime (s, m, "%-5M%_5M%05M%-5S%_5S%05S%-5u%_5u%05u%-5U%_5U%05U", tp);
+  strftime (s, m, "%-5V%_5V%05V%-5w%_5w%05w%-5W%_5W%05W%-5Y%_5Y%05Y", tp);
+  /* Correct usages with GNU extension conversion characters.  */
+  strftime (s, m, "%-5k%_5k%05k%-5l%_5l%05l%-20s%_20s%020s", tp);
+  /* Correct usages with Y2K problems.  */
+  strftime (s, m, "%-5g%_5g%05g%-5y%_5y%05y", tp); /* { dg-warning "only last 2" "2-digit year" } */
+  /* Incorrect usages.  */
+  strftime (s, m, "%5a", tp); /* { dg-warning "width" "bad %a" } */
+  strftime (s, m, "%-a", tp); /* { dg-warning "flag" "bad %a" } */
+  strftime (s, m, "%_a", tp); /* { dg-warning "flag" "bad %a" } */
+  strftime (s, m, "%0a", tp); /* { dg-warning "flag" "bad %a" } */
+  strftime (s, m, "%5A", tp); /* { dg-warning "width" "bad %A" } */
+  strftime (s, m, "%-A", tp); /* { dg-warning "flag" "bad %A" } */
+  strftime (s, m, "%_A", tp); /* { dg-warning "flag" "bad %A" } */
+  strftime (s, m, "%0A", tp); /* { dg-warning "flag" "bad %A" } */
+  strftime (s, m, "%5b", tp); /* { dg-warning "width" "bad %b" } */
+  strftime (s, m, "%-b", tp); /* { dg-warning "flag" "bad %b" } */
+  strftime (s, m, "%_b", tp); /* { dg-warning "flag" "bad %b" } */
+  strftime (s, m, "%0b", tp); /* { dg-warning "flag" "bad %b" } */
+  strftime (s, m, "%5B", tp); /* { dg-warning "width" "bad %B" } */
+  strftime (s, m, "%-B", tp); /* { dg-warning "flag" "bad %B" } */
+  strftime (s, m, "%_B", tp); /* { dg-warning "flag" "bad %B" } */
+  strftime (s, m, "%0B", tp); /* { dg-warning "flag" "bad %B" } */
+  strftime (s, m, "%5F", tp); /* { dg-warning "width" "bad %F" } */
+  strftime (s, m, "%-F", tp); /* { dg-warning "flag" "bad %F" } */
+  strftime (s, m, "%_F", tp); /* { dg-warning "flag" "bad %F" } */
+  strftime (s, m, "%0F", tp); /* { dg-warning "flag" "bad %F" } */
+  strftime (s, m, "%5h", tp); /* { dg-warning "width" "bad %h" } */
+  strftime (s, m, "%-h", tp); /* { dg-warning "flag" "bad %h" } */
+  strftime (s, m, "%_h", tp); /* { dg-warning "flag" "bad %h" } */
+  strftime (s, m, "%0h", tp); /* { dg-warning "flag" "bad %h" } */
+  strftime (s, m, "%5n", tp); /* { dg-warning "width" "bad %n" } */
+  strftime (s, m, "%-n", tp); /* { dg-warning "flag" "bad %n" } */
+  strftime (s, m, "%_n", tp); /* { dg-warning "flag" "bad %n" } */
+  strftime (s, m, "%0n", tp); /* { dg-warning "flag" "bad %n" } */
+  strftime (s, m, "%5p", tp); /* { dg-warning "width" "bad %p" } */
+  strftime (s, m, "%-p", tp); /* { dg-warning "flag" "bad %p" } */
+  strftime (s, m, "%_p", tp); /* { dg-warning "flag" "bad %p" } */
+  strftime (s, m, "%0p", tp); /* { dg-warning "flag" "bad %p" } */
+  strftime (s, m, "%5r", tp); /* { dg-warning "width" "bad %r" } */
+  strftime (s, m, "%-r", tp); /* { dg-warning "flag" "bad %r" } */
+  strftime (s, m, "%_r", tp); /* { dg-warning "flag" "bad %r" } */
+  strftime (s, m, "%0r", tp); /* { dg-warning "flag" "bad %r" } */
+  strftime (s, m, "%5R", tp); /* { dg-warning "width" "bad %R" } */
+  strftime (s, m, "%-R", tp); /* { dg-warning "flag" "bad %R" } */
+  strftime (s, m, "%_R", tp); /* { dg-warning "flag" "bad %R" } */
+  strftime (s, m, "%0R", tp); /* { dg-warning "flag" "bad %R" } */
+  strftime (s, m, "%5t", tp); /* { dg-warning "width" "bad %t" } */
+  strftime (s, m, "%-t", tp); /* { dg-warning "flag" "bad %t" } */
+  strftime (s, m, "%_t", tp); /* { dg-warning "flag" "bad %t" } */
+  strftime (s, m, "%0t", tp); /* { dg-warning "flag" "bad %t" } */
+  strftime (s, m, "%5T", tp); /* { dg-warning "width" "bad %T" } */
+  strftime (s, m, "%-T", tp); /* { dg-warning "flag" "bad %T" } */
+  strftime (s, m, "%_T", tp); /* { dg-warning "flag" "bad %T" } */
+  strftime (s, m, "%0T", tp); /* { dg-warning "flag" "bad %T" } */
+  strftime (s, m, "%5X", tp); /* { dg-warning "width" "bad %X" } */
+  strftime (s, m, "%-X", tp); /* { dg-warning "flag" "bad %X" } */
+  strftime (s, m, "%_X", tp); /* { dg-warning "flag" "bad %X" } */
+  strftime (s, m, "%0X", tp); /* { dg-warning "flag" "bad %X" } */
+  strftime (s, m, "%5z", tp); /* { dg-warning "width" "bad %z" } */
+  strftime (s, m, "%-z", tp); /* { dg-warning "flag" "bad %z" } */
+  strftime (s, m, "%_z", tp); /* { dg-warning "flag" "bad %z" } */
+  strftime (s, m, "%0z", tp); /* { dg-warning "flag" "bad %z" } */
+  strftime (s, m, "%5Z", tp); /* { dg-warning "width" "bad %Z" } */
+  strftime (s, m, "%-Z", tp); /* { dg-warning "flag" "bad %Z" } */
+  strftime (s, m, "%_Z", tp); /* { dg-warning "flag" "bad %Z" } */
+  strftime (s, m, "%0Z", tp); /* { dg-warning "flag" "bad %Z" } */
+  /* Incorrect usages with Y2K problems.  */
+  strftime (s, m, "%5c", tp); /* { dg-warning "width" "bad %c" } */
+  strftime (s, m, "%-c", tp); /* { dg-warning "flag" "bad %c" } */
+  strftime (s, m, "%_c", tp); /* { dg-warning "flag" "bad %c" } */
+  strftime (s, m, "%0c", tp); /* { dg-warning "flag" "bad %c" } */
+  strftime (s, m, "%5D", tp); /* { dg-warning "width" "bad %D" } */
+  strftime (s, m, "%-D", tp); /* { dg-warning "flag" "bad %D" } */
+  strftime (s, m, "%_D", tp); /* { dg-warning "flag" "bad %D" } */
+  strftime (s, m, "%0D", tp); /* { dg-warning "flag" "bad %D" } */
+  strftime (s, m, "%5x", tp); /* { dg-warning "width" "bad %x" } */
+  strftime (s, m, "%-x", tp); /* { dg-warning "flag" "bad %x" } */
+  strftime (s, m, "%_x", tp); /* { dg-warning "flag" "bad %x" } */
+  strftime (s, m, "%0x", tp); /* { dg-warning "flag" "bad %x" } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 93 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 94 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 95 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 96 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 97 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 98 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 99 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 100 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 101 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 102 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 103 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 104 } */
+  /* Incorrect usages with GNU extension conversion characters.  */
+  strftime (s, m, "%5P", tp); /* { dg-warning "width" "bad %P" } */
+  strftime (s, m, "%-P", tp); /* { dg-warning "flag" "bad %P" } */
+  strftime (s, m, "%_P", tp); /* { dg-warning "flag" "bad %P" } */
+  strftime (s, m, "%0P", tp); /* { dg-warning "flag" "bad %P" } */
+  /* The "^" and "#" flags control the case of the output.
+     ^ (uppercase) makes sense on aAbBhZ; # (change case) makes sense
+     on the same and on p.
+  */
+  strftime (s, m, "%^a%#a%^A%#A%^b%#b%^B%#B%^h%#h%^Z%#Z%#p", tp);
+  /* Bad usages.  */
+  strftime (s, m, "%^C", tp); /* { dg-warning "flag" "bad %C" } */
+  strftime (s, m, "%#C", tp); /* { dg-warning "flag" "bad %C" } */
+  strftime (s, m, "%^d", tp); /* { dg-warning "flag" "bad %d" } */
+  strftime (s, m, "%#d", tp); /* { dg-warning "flag" "bad %d" } */
+  strftime (s, m, "%^e", tp); /* { dg-warning "flag" "bad %e" } */
+  strftime (s, m, "%#e", tp); /* { dg-warning "flag" "bad %e" } */
+  strftime (s, m, "%^F", tp); /* { dg-warning "flag" "bad %F" } */
+  strftime (s, m, "%#F", tp); /* { dg-warning "flag" "bad %F" } */
+  strftime (s, m, "%^G", tp); /* { dg-warning "flag" "bad %G" } */
+  strftime (s, m, "%#G", tp); /* { dg-warning "flag" "bad %G" } */
+  strftime (s, m, "%^H", tp); /* { dg-warning "flag" "bad %H" } */
+  strftime (s, m, "%#H", tp); /* { dg-warning "flag" "bad %H" } */
+  strftime (s, m, "%^I", tp); /* { dg-warning "flag" "bad %I" } */
+  strftime (s, m, "%#I", tp); /* { dg-warning "flag" "bad %I" } */
+  strftime (s, m, "%^j", tp); /* { dg-warning "flag" "bad %j" } */
+  strftime (s, m, "%#j", tp); /* { dg-warning "flag" "bad %j" } */
+  strftime (s, m, "%^m", tp); /* { dg-warning "flag" "bad %m" } */
+  strftime (s, m, "%#m", tp); /* { dg-warning "flag" "bad %m" } */
+  strftime (s, m, "%^M", tp); /* { dg-warning "flag" "bad %M" } */
+  strftime (s, m, "%#M", tp); /* { dg-warning "flag" "bad %M" } */
+  strftime (s, m, "%^n", tp); /* { dg-warning "flag" "bad %n" } */
+  strftime (s, m, "%#n", tp); /* { dg-warning "flag" "bad %n" } */
+  strftime (s, m, "%^p", tp); /* { dg-warning "flag" "bad %p" } */
+  strftime (s, m, "%^r", tp); /* { dg-warning "flag" "bad %r" } */
+  strftime (s, m, "%#r", tp); /* { dg-warning "flag" "bad %r" } */
+  strftime (s, m, "%^R", tp); /* { dg-warning "flag" "bad %R" } */
+  strftime (s, m, "%#R", tp); /* { dg-warning "flag" "bad %R" } */
+  strftime (s, m, "%^S", tp); /* { dg-warning "flag" "bad %S" } */
+  strftime (s, m, "%#S", tp); /* { dg-warning "flag" "bad %S" } */
+  strftime (s, m, "%^t", tp); /* { dg-warning "flag" "bad %t" } */
+  strftime (s, m, "%#t", tp); /* { dg-warning "flag" "bad %t" } */
+  strftime (s, m, "%^T", tp); /* { dg-warning "flag" "bad %T" } */
+  strftime (s, m, "%#T", tp); /* { dg-warning "flag" "bad %T" } */
+  strftime (s, m, "%^u", tp); /* { dg-warning "flag" "bad %u" } */
+  strftime (s, m, "%#u", tp); /* { dg-warning "flag" "bad %u" } */
+  strftime (s, m, "%^U", tp); /* { dg-warning "flag" "bad %U" } */
+  strftime (s, m, "%#U", tp); /* { dg-warning "flag" "bad %U" } */
+  strftime (s, m, "%^V", tp); /* { dg-warning "flag" "bad %V" } */
+  strftime (s, m, "%#V", tp); /* { dg-warning "flag" "bad %V" } */
+  strftime (s, m, "%^w", tp); /* { dg-warning "flag" "bad %w" } */
+  strftime (s, m, "%#w", tp); /* { dg-warning "flag" "bad %w" } */
+  strftime (s, m, "%^W", tp); /* { dg-warning "flag" "bad %W" } */
+  strftime (s, m, "%#W", tp); /* { dg-warning "flag" "bad %W" } */
+  strftime (s, m, "%^X", tp); /* { dg-warning "flag" "bad %X" } */
+  strftime (s, m, "%#X", tp); /* { dg-warning "flag" "bad %X" } */
+  strftime (s, m, "%^Y", tp); /* { dg-warning "flag" "bad %Y" } */
+  strftime (s, m, "%#Y", tp); /* { dg-warning "flag" "bad %Y" } */
+  strftime (s, m, "%^z", tp); /* { dg-warning "flag" "bad %z" } */
+  strftime (s, m, "%#z", tp); /* { dg-warning "flag" "bad %z" } */
+  strftime (s, m, "%^P", tp); /* { dg-warning "flag" "bad %P" } */
+  strftime (s, m, "%#P", tp); /* { dg-warning "flag" "bad %P" } */
+  strftime (s, m, "%^k", tp); /* { dg-warning "flag" "bad %k" } */
+  strftime (s, m, "%#k", tp); /* { dg-warning "flag" "bad %k" } */
+  strftime (s, m, "%^l", tp); /* { dg-warning "flag" "bad %l" } */
+  strftime (s, m, "%#l", tp); /* { dg-warning "flag" "bad %l" } */
+  strftime (s, m, "%^s", tp); /* { dg-warning "flag" "bad %s" } */
+  strftime (s, m, "%#s", tp); /* { dg-warning "flag" "bad %s" } */
+  /* Bad usages with Y2K problems.  */
+  strftime (s, m, "%^c", tp); /* { dg-warning "flag" "bad %c" } */
+  strftime (s, m, "%#c", tp); /* { dg-warning "flag" "bad %c" } */
+  strftime (s, m, "%^D", tp); /* { dg-warning "flag" "bad %D" } */
+  strftime (s, m, "%#D", tp); /* { dg-warning "flag" "bad %D" } */
+  strftime (s, m, "%^g", tp); /* { dg-warning "flag" "bad %g" } */
+  strftime (s, m, "%#g", tp); /* { dg-warning "flag" "bad %g" } */
+  strftime (s, m, "%^x", tp); /* { dg-warning "flag" "bad %x" } */
+  strftime (s, m, "%#x", tp); /* { dg-warning "flag" "bad %x" } */
+  strftime (s, m, "%^y", tp); /* { dg-warning "flag" "bad %y" } */
+  strftime (s, m, "%#y", tp); /* { dg-warning "flag" "bad %y" } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 186 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 187 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 188 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 189 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 190 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 191 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 192 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 193 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 194 } */
+  /* { dg-warning "only last 2" "2-digit year" { target *-*-* } 195 } */
+  /* GCC also accepts the glibc format extensions %P, %k, %l, %s.  */
+  strftime (s, m, "%P%k%l%s", tp);
+  /* GCC also accepts the glibc extension of the "O" modifier on some
+     more formats.  The cases where it is rejected altogether are
+     covered in c99-strftime-1.c, except for the extension %P.
+  */
+  strftime (s, m, "%OC%Og%OG%Oj%OY%Oz%Ok%Ol%Os", tp); /* { dg-warning "only last 2" "2-digit year" } */
+  strftime (s, m, "%OP", tp); /* { dg-warning "flag|modifier" "bad %OP" } */
+  /* The "-", "_" and "0" flags are mutually exclusive.  */
+  strftime (s, m, "%-_5C", tp); /* { dg-warning "flag" "bad %-_" } */
+  strftime (s, m, "%-05C", tp); /* { dg-warning "flag" "bad %-0" } */
+  strftime (s, m, "%_05C", tp); /* { dg-warning "flag" "bad %_0" } */
+  /* The "#" and "^" flags are mutually exclusive.  */
+  strftime (s, m, "%^#a", tp); /* { dg-warning "flag" "bad %^#" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/ext-4.c b/gcc/testsuite/gcc.dg/format/ext-4.c
new file mode 100644 (file)
index 0000000..c0cf740
--- /dev/null
@@ -0,0 +1,20 @@
+/* Test for scanf formats.  %a extensions.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu89 -Wformat" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+extern int scanf (const char *, ...);
+
+void
+foo (char **sp, wchar_t **lsp)
+{
+  /* %a formats for allocation, only recognised in C90 mode, are a
+     GNU extension.  Followed by other characters, %a is not treated
+     specially.
+  */
+  scanf ("%as", sp);
+  scanf ("%aS", lsp);
+  scanf ("%a[bcd]", sp);
+}
diff --git a/gcc/testsuite/gcc.dg/format/ext-5.c b/gcc/testsuite/gcc.dg/format/ext-5.c
new file mode 100644 (file)
index 0000000..e3cce44
--- /dev/null
@@ -0,0 +1,21 @@
+/* Test for gettext default attributes.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat" } */
+
+extern int printf (const char *, ...);
+
+extern char *gettext (const char *);
+extern char *dgettext (const char *, const char *);
+extern char *dcgettext (const char *, const char *, int);
+
+void
+foo (int i, long l)
+{
+  printf (gettext ("%d"), i);
+  printf (gettext ("%ld"), i); /* { dg-warning "format" "gettext" } */
+  printf (dgettext ("", "%d"), i);
+  printf (dgettext ("", "%ld"), i); /* { dg-warning "format" "dgettext" } */
+  printf (dcgettext ("", "%d", 0), i);
+  printf (dcgettext ("", "%ld", 0), i); /* { dg-warning "format" "dcgettext" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/format.exp b/gcc/testsuite/gcc.dg/format/format.exp
new file mode 100644 (file)
index 0000000..90695fc
--- /dev/null
@@ -0,0 +1,61 @@
+#   Copyright (C) 1997, 2000, 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gcc@prep.ai.mit.edu
+
+# Don't run this directory with any default CFLAGS, but run tests with
+# and without -DWIDE.
+
+if [info exists TORTURE_OPTIONS] {
+    set old_TORTURE_OPTIONS $TORTURE_OPTIONS
+} elseif [info exists old_TORTURE_OPTIONS] {
+    unset old_TORTURE_OPTIONS
+}
+if [info exists torture_with_loops] {
+    set old_torture_with_loops $torture_with_loops
+} elseif [info exists old_torture_with_loops] {
+    unset old_torture_with_loops
+}
+if [info exists torture_without_loops] {
+    set old_torture_without_loops $torture_without_loops
+} elseif [info exists old_torture_without_loops] {
+    unset old_torture_without_loops
+}
+set TORTURE_OPTIONS [list { } { -DWIDE } ]
+set torture_with_loops [list { } { -DWIDE } ]
+set torture_without_loops [list { } { -DWIDE } ]
+
+load_lib gcc-dg.exp
+
+dg-init
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] ""
+if [info exists old_TORTURE_OPTIONS] {
+    set TORTURE_OPTIONS $old_TORTURE_OPTIONS
+} else {
+    unset TORTURE_OPTIONS
+}
+if [info exists old_torture_with_loops] {
+    set torture_with_loops $old_torture_with_loops
+} else {
+    unset torture_with_loops
+}
+if [info exists old_torture_without_loops] {
+    set torture_without_loops $old_torture_without_loops
+} else {
+    unset torture_without_loops
+}
+dg-finish
diff --git a/gcc/testsuite/gcc.dg/format/miss-1.c b/gcc/testsuite/gcc.dg/format/miss-1.c
new file mode 100644 (file)
index 0000000..a5d467a
--- /dev/null
@@ -0,0 +1,42 @@
+/* Test for warnings for missing format attributes.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat -Wmissing-format-attribute" } */
+
+#include <stdarg.h>
+
+extern int vprintf (const char *restrict, va_list);
+extern int vscanf (const char *restrict, va_list);
+
+void
+foo (const char *fmt, ...)
+{
+  va_list ap;
+  va_start (ap, fmt);
+  vprintf (fmt, ap); /* { dg-warning "candidate" "printf attribute warning" } */
+  va_end (ap);
+}
+
+void
+bar (const char *fmt, ...)
+{
+  va_list ap;
+  va_start (ap, fmt);
+  vscanf (fmt, ap); /* { dg-warning "candidate" "scanf attribute warning" } */
+  va_end (ap);
+}
+
+__attribute__((__format__(__printf__, 1, 2))) void
+foo2 (const char *fmt, ...)
+{
+  va_list ap;
+  va_start (ap, fmt);
+  vprintf (fmt, ap);
+  va_end (ap);
+}
+
+void
+vfoo (const char *fmt, va_list arg)
+{
+  vprintf (fmt, arg); /* { dg-warning "candidate" "printf attribute warning 2" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/miss-2.c b/gcc/testsuite/gcc.dg/format/miss-2.c
new file mode 100644 (file)
index 0000000..b7c5501
--- /dev/null
@@ -0,0 +1,18 @@
+/* Test for warnings for missing format attributes.  Don't warn if no
+   relevant parameters for a format attribute; see c/1017.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat -Wmissing-format-attribute" } */
+
+#include <stdarg.h>
+
+extern int vprintf (const char *restrict, va_list);
+
+void
+foo (int i, ...)
+{
+  va_list ap;
+  va_start (ap, i);
+  vprintf ("Foo %s bar %s", ap); /* { dg-bogus "candidate" "bogus printf attribute warning" } */
+  va_end (ap);
+}
diff --git a/gcc/testsuite/gcc.dg/format/no-exargs-1.c b/gcc/testsuite/gcc.dg/format/no-exargs-1.c
new file mode 100644 (file)
index 0000000..bbf5a8a
--- /dev/null
@@ -0,0 +1,14 @@
+/* Test for warnings for extra format arguments being disabled by
+   -Wno-format-extra-args.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat -Wno-format-extra-args" } */
+
+extern int printf (const char *, ...);
+
+void
+foo (int i)
+{
+  printf ("foo", i);
+  printf ("%1$d", i, i);
+}
diff --git a/gcc/testsuite/gcc.dg/format/no-y2k-1.c b/gcc/testsuite/gcc.dg/format/no-y2k-1.c
new file mode 100644 (file)
index 0000000..e41d26d
--- /dev/null
@@ -0,0 +1,16 @@
+/* Test for warnings for Y2K problems being disabled by -Wno-format-y2k.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat -Wno-format-y2k" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+struct tm;
+
+extern size_t strftime (char *, size_t, const char *, const struct tm *);
+
+void
+foo (char *s, size_t m, const struct tm *tp)
+{
+  strftime (s, m, "%y%c%x", tp);
+}
diff --git a/gcc/testsuite/gcc.dg/format/nonlit-1.c b/gcc/testsuite/gcc.dg/format/nonlit-1.c
new file mode 100644 (file)
index 0000000..e40bf08
--- /dev/null
@@ -0,0 +1,13 @@
+/* Test for warnings for non-string-literal formats.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat -Wformat-nonliteral" } */
+
+extern int printf (const char *, ...);
+
+void
+foo (char *s, __SIZE_TYPE__ i)
+{
+  printf ((const char *)i, i); /* { dg-warning "argument types" "non-literal" } */
+  printf (s, i); /* { dg-warning "argument types" "non-literal" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/nonlit-2.c b/gcc/testsuite/gcc.dg/format/nonlit-2.c
new file mode 100644 (file)
index 0000000..9c3eee8
--- /dev/null
@@ -0,0 +1,13 @@
+/* Test for warnings for non-string-literal formats.  Test with -Wformat=2.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat=2" } */
+
+extern int printf (const char *, ...);
+
+void
+foo (char *s, __SIZE_TYPE__ i)
+{
+  printf ((const char *)i, i); /* { dg-warning "argument types" "non-literal" } */
+  printf (s, i); /* { dg-warning "argument types" "non-literal" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/nonlit-3.c b/gcc/testsuite/gcc.dg/format/nonlit-3.c
new file mode 100644 (file)
index 0000000..4423151
--- /dev/null
@@ -0,0 +1,16 @@
+/* Test for warnings for non-string-literal formats.  Test for strftime formats.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat -Wformat-nonliteral" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+struct tm;
+
+extern size_t strftime (char *, size_t, const char *, const struct tm *);
+
+void
+foo (char *s, size_t m, const struct tm *tp, char *fmt)
+{
+  strftime (s, m, fmt, tp); /* { dg-warning "format string" "non-literal" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/sec-1.c b/gcc/testsuite/gcc.dg/format/sec-1.c
new file mode 100644 (file)
index 0000000..5ca4905
--- /dev/null
@@ -0,0 +1,12 @@
+/* Test for security warning when non-literal format has no arguments.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat -Wformat-security" } */
+
+extern int printf (const char *, ...);
+
+void
+foo (char *s)
+{
+  printf (s); /* { dg-warning "no format arguments" "security warning" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/strfmon-1.c b/gcc/testsuite/gcc.dg/format/strfmon-1.c
new file mode 100644 (file)
index 0000000..40d44c1
--- /dev/null
@@ -0,0 +1,68 @@
+/* Test for strfmon format checking.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+/* Kludge to get something that may be ssize_t.  */
+#define unsigned signed
+typedef __SIZE_TYPE__ ssize_t;
+#undef unsigned
+
+#define NULL ((void *)0)
+
+extern ssize_t strfmon (char *restrict, size_t, const char *restrict, ...);
+
+void
+foo (char *s, size_t m, double d, long double ld)
+{
+  /* Examples of valid formats from Austin Group draft 5.  */
+  strfmon (s, m, "%n", d);
+  strfmon (s, m, "%11n", d);
+  strfmon (s, m, "%#5n", d);
+  strfmon (s, m, "%=*#5n", d);
+  strfmon (s, m, "%=0#5n", d);
+  strfmon (s, m, "%^#5n", d);
+  strfmon (s, m, "%^#5.0n", d);
+  strfmon (s, m, "%^#5.4n", d);
+  strfmon (s, m, "%(#5n", d);
+  strfmon (s, m, "%(!#5n", d);
+  /* Some more valid formats, including the GNU L length extension.  */
+  strfmon (s, m, "abc%-11ndef%==i%%", d, d);
+  strfmon (s, m, "%%abc%-11ndef%==Li%=%i", d, ld, d);
+  strfmon (s, m, "%Li", ld);
+  strfmon (s, m, "%11Li", ld);
+  strfmon (s, m, "%#5Li", ld);
+  strfmon (s, m, "%=*#5Li", ld);
+  strfmon (s, m, "%=0#5Li", ld);
+  strfmon (s, m, "%^#5Li", ld);
+  strfmon (s, m, "%^#5.0Li", ld);
+  strfmon (s, m, "%^#5.4Li", ld);
+  strfmon (s, m, "%(#5Li", ld);
+  strfmon (s, m, "%(!#5Li", ld);
+  /* Formats with the wrong types used.  */
+  strfmon (s, m, "%Ln", d); /* { dg-warning "format" "wrong type" } */
+  strfmon (s, m, "%n", ld); /* { dg-warning "format" "wrong type" } */
+  /* The + and ( flags cannot be used together.  */
+  strfmon (s, m, "%+(i", d); /* { dg-warning "flag" "+ and ( flags" } */
+  strfmon (s, m, "%(+i", d); /* { dg-warning "flag" "+ and ( flags" } */
+  /* Although empty precision is OK for printf, it isn't here.  */
+  strfmon (s, m, "%#.5n", d); /* { dg-warning "empty" "empty left precision" } */
+  strfmon (s, m, "%#5.n", d); /* { dg-warning "empty" "empty right precision" } */
+  /* However, zero is a valid value for width and precisions.  */
+  strfmon (s, m, "%0#0.0n", d);
+  /* Test bogus %% constructions.  */
+  strfmon (s, m, "%^%"); /* { dg-warning "format" "bogus %%" } */
+  strfmon (s, m, "%!%\n"); /* { dg-warning "format" "bogus %%" } */
+  strfmon (s, m, "%5%\n"); /* { dg-warning "format" "bogus %%" } */
+  strfmon (s, m, "%.5%\n"); /* { dg-warning "format" "bogus %%" } */
+  strfmon (s, m, "%#5%\n"); /* { dg-warning "format" "bogus %%" } */
+  /* Miscellaneous bogus formats.  */
+  strfmon (s, m, "%n%n", d); /* { dg-warning "arguments" "too few args" } */
+  strfmon (s, m, ""); /* { dg-warning "zero-length" "empty" } */
+  strfmon (s, m, NULL); /* { dg-warning "null" "null format string" } */
+  strfmon (s, m, "%"); /* { dg-warning "trailing" "tailing %" } */
+  strfmon (s, m, "%n\0", d); /* { dg-warning "embedded" "embedded NUL" } */
+  strfmon (s, m, "%^^n", d); /* { dg-warning "repeated" "repeated flag" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/va-1.c b/gcc/testsuite/gcc.dg/format/va-1.c
new file mode 100644 (file)
index 0000000..9538e2b
--- /dev/null
@@ -0,0 +1,13 @@
+/* Test for strange warning in format checking.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-Wformat" } */
+
+extern int printf (const char *, ...);
+
+void
+foo (void *p)
+{
+  printf ("%d", p); /* { dg-bogus "va_list" "wrong type in format warning" } */
+  /* { dg-warning "format" "format error" { target *-*-* } 11 } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/warnll-1.c b/gcc/testsuite/gcc.dg/format/warnll-1.c
new file mode 100644 (file)
index 0000000..71a749b
--- /dev/null
@@ -0,0 +1,46 @@
+/* Test for printf formats.  C99 "long long" formats should be accepted with
+   -Wno-long-long.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat -Wno-long-long" } */
+
+extern int printf (const char *, ...);
+extern int scanf (const char *, ...);
+
+void
+foo (long long ll, unsigned long long ull, long long *lln,
+     long long *llp, unsigned long long *ullp)
+{
+  /* Test for accepting standard "long long" formats.  */
+  printf ("%lld%lli%llo%llu%llx%llX%lln", ll, ll, ull, ull, ull, ull, lln);
+  scanf ("%lld%lli%llo%llu%llx%llX%lln", llp, llp,
+        ullp, ullp, ullp, ullp, lln);
+  /* Use of "q" and "L" should still be warned about.  */
+  printf ("%qd", ll); /* { dg-warning "C" "printf %qd" } */
+  printf ("%qi", ll); /* { dg-warning "C" "printf %qi" } */
+  printf ("%qo", ull); /* { dg-warning "C" "printf %qo" } */
+  printf ("%qu", ull); /* { dg-warning "C" "printf %qu" } */
+  printf ("%qx", ull); /* { dg-warning "C" "printf %qx" } */
+  printf ("%qX", ull); /* { dg-warning "C" "printf %qX" } */
+  printf ("%qn", lln); /* { dg-warning "C" "printf %qn" } */
+  printf ("%Ld", ll); /* { dg-warning "C" "printf %Ld" } */
+  printf ("%Li", ll); /* { dg-warning "C" "printf %Li" } */
+  printf ("%Lo", ull); /* { dg-warning "C" "printf %oL" } */
+  printf ("%Lu", ull); /* { dg-warning "C" "printf %Lu" } */
+  printf ("%Lx", ull); /* { dg-warning "C" "printf %Lx" } */
+  printf ("%LX", ull); /* { dg-warning "C" "printf %LX" } */
+  scanf ("%qd", llp); /* { dg-warning "C" "scanf %qd" } */
+  scanf ("%qi", llp); /* { dg-warning "C" "scanf %qi" } */
+  scanf ("%qo", ullp); /* { dg-warning "C" "scanf %qo" } */
+  scanf ("%qu", ullp); /* { dg-warning "C" "scanf %qu" } */
+  scanf ("%qx", ullp); /* { dg-warning "C" "scanf %qx" } */
+  scanf ("%qX", ullp); /* { dg-warning "C" "scanf %qX" } */
+  scanf ("%qn", lln); /* { dg-warning "C" "scanf %qn" } */
+  scanf ("%Ld", llp); /* { dg-warning "C" "scanf %Ld" } */
+  scanf ("%Li", llp); /* { dg-warning "C" "scanf %Li" } */
+  scanf ("%Lo", ullp); /* { dg-warning "C" "scanf %oL" } */
+  scanf ("%Lu", ullp); /* { dg-warning "C" "scanf %Lu" } */
+  scanf ("%Lx", ullp); /* { dg-warning "C" "scanf %Lx" } */
+  scanf ("%LX", ullp); /* { dg-warning "C" "scanf %LX" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/xopen-1.c b/gcc/testsuite/gcc.dg/format/xopen-1.c
new file mode 100644 (file)
index 0000000..99d571b
--- /dev/null
@@ -0,0 +1,122 @@
+/* Test for X/Open format extensions, as found in the
+   Single Unix Specification and in Austin Group draft 4, subject to some
+   Aardvark problem reports approved as changes.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+typedef __WINT_TYPE__ wint_t;
+typedef __builtin_va_list va_list;
+
+extern int printf (const char *, ...);
+extern int vprintf (const char *, va_list);
+extern int scanf (const char *, ...);
+
+void
+foo (int i, unsigned int u, wint_t lc, wchar_t *ls, int *ip, double d,
+     char *s, void *p, int *n, long int l, int i2, float *fp, long int *lp,
+     va_list va)
+{
+  /* The conversion specifiers C and S, for both printf and scanf,
+     are X/Open extensions.
+  */
+  printf ("%C", lc);
+  printf ("%3C", lc);
+  printf ("%.3C", lc); /* { dg-warning "precision" "precision with %C" } */
+  printf ("%hC", lc); /* { dg-warning "length" "bad %hC" } */
+  printf ("%hhC", lc); /* { dg-warning "length" "bad %hhC" } */
+  printf ("%lC", lc); /* { dg-warning "length" "bad %lC" } */
+  printf ("%llC", lc); /* { dg-warning "length" "bad %llC" } */
+  printf ("%jC", lc); /* { dg-warning "length" "bad %jC" } */
+  printf ("%zC", lc); /* { dg-warning "length" "bad %zC" } */
+  printf ("%tC", lc); /* { dg-warning "length" "bad %tC" } */
+  printf ("%LC", lc); /* { dg-warning "length" "bad %LC" } */
+  printf ("%-C", lc);
+  printf ("%+C", lc); /* { dg-warning "flag" "bad %+C" } */
+  printf ("% C", lc); /* { dg-warning "flag" "bad % C" } */
+  printf ("%#C", lc); /* { dg-warning "flag" "bad %#C" } */
+  printf ("%0C", lc); /* { dg-warning "flag" "bad %0C" } */
+  printf ("%'C", lc); /* { dg-warning "flag" "bad %'C" } */
+  printf ("%S", ls);
+  printf ("%3S", ls);
+  printf ("%.3S", ls);
+  printf ("%hS", ls); /* { dg-warning "length" "bad %hS" } */
+  printf ("%hhS", ls); /* { dg-warning "length" "bad %hhS" } */
+  printf ("%lS", ls); /* { dg-warning "length" "bad %lS" } */
+  printf ("%llS", ls); /* { dg-warning "length" "bad %llS" } */
+  printf ("%jS", ls); /* { dg-warning "length" "bad %jS" } */
+  printf ("%zS", ls); /* { dg-warning "length" "bad %zS" } */
+  printf ("%tS", ls); /* { dg-warning "length" "bad %tS" } */
+  printf ("%LS", ls); /* { dg-warning "length" "bad %LS" } */
+  printf ("%-S", ls);
+  printf ("%+S", ls); /* { dg-warning "flag" "bad %+S" } */
+  printf ("% S", ls); /* { dg-warning "flag" "bad % S" } */
+  printf ("%#S", ls); /* { dg-warning "flag" "bad %#S" } */
+  printf ("%0S", ls); /* { dg-warning "flag" "bad %0S" } */
+  printf ("%'S", ls); /* { dg-warning "flag" "bad %'S" } */
+  scanf ("%C", ls);
+  scanf ("%S", ls);
+  scanf ("%*C%*S");
+  scanf ("%2C%3S", ls, ls);
+  scanf ("%hC", ls); /* { dg-warning "length" "bad %hC" } */
+  scanf ("%hhC", ls); /* { dg-warning "length" "bad %hhC" } */
+  scanf ("%lC", ls); /* { dg-warning "length" "bad %lC" } */
+  scanf ("%llC", ls); /* { dg-warning "length" "bad %llC" } */
+  scanf ("%jC", ls); /* { dg-warning "length" "bad %jC" } */
+  scanf ("%zC", ls); /* { dg-warning "length" "bad %zC" } */
+  scanf ("%tC", ls); /* { dg-warning "length" "bad %tC" } */
+  scanf ("%LC", ls); /* { dg-warning "length" "bad %LC" } */
+  scanf ("%hS", ls); /* { dg-warning "length" "bad %hS" } */
+  scanf ("%hhS", ls); /* { dg-warning "length" "bad %hhS" } */
+  scanf ("%lS", ls); /* { dg-warning "length" "bad %lS" } */
+  scanf ("%llS", ls); /* { dg-warning "length" "bad %llS" } */
+  scanf ("%jS", ls); /* { dg-warning "length" "bad %jS" } */
+  scanf ("%zS", ls); /* { dg-warning "length" "bad %zS" } */
+  scanf ("%tS", ls); /* { dg-warning "length" "bad %tS" } */
+  scanf ("%LS", ls); /* { dg-warning "length" "bad %LS" } */
+  /* In C99 mode (even with extensions), %aS is a floating point
+     format followed by an S.
+  */
+  scanf ("%aS", fp);
+  /* The printf flag character ' is an X/Open extension.  */
+  printf ("%'d%'i%'u%'f%'F%'g%'G", i, i, u, d, d, d, d);
+  printf ("%'o", u); /* { dg-warning "flag" "bad use of ' flag" } */
+  printf ("%'x", u); /* { dg-warning "flag" "bad use of ' flag" } */
+  printf ("%'X", u); /* { dg-warning "flag" "bad use of ' flag" } */
+  printf ("%'e", d); /* { dg-warning "flag" "bad use of ' flag" } */
+  printf ("%'E", d); /* { dg-warning "flag" "bad use of ' flag" } */
+  printf ("%'a", d); /* { dg-warning "flag" "bad use of ' flag" } */
+  printf ("%'A", d); /* { dg-warning "flag" "bad use of ' flag" } */
+  printf ("%'c", i); /* { dg-warning "flag" "bad use of ' flag" } */
+  printf ("%'s", s); /* { dg-warning "flag" "bad use of ' flag" } */
+  printf ("%'p", p); /* { dg-warning "flag" "bad use of ' flag" } */
+  printf ("%'n", n); /* { dg-warning "flag" "bad use of ' flag" } */
+  /* The use of operand number $ formats is an X/Open extension.  */
+  /* Banning gaps in the arguments used with scanf was covered in Aardvark
+     report XSHd4 ERN 164, which was rejected, but implementation without
+     such a ban still isn't possible within ISO C.
+  */
+  scanf ("%1$d", ip);
+  printf ("%1$d", i);
+  printf ("%1$d", l); /* { dg-warning "arg 2" "mismatched args with $ format" } */
+  printf ("%3$*2$.*1$ld", i2, i, l);
+  printf ("%4$ld%7$ld%5$d%6$d%3$d%1$d%2$d", i, i, i, l, i, i, l);
+  scanf ("%4$ld%7$ld%5$d%6$d%3$d%1$d%2$d", ip, ip, ip, lp, ip, ip, lp);
+  printf ("%1$d%d", i, i); /* { dg-warning "missing" "mixing $ and non-$ formats" } */
+  printf ("%%%1$d%%%2$d", i, i);
+  printf ("%d%2$d", i); /* { dg-warning "type character" "mixing $ and non-$ formats" } */
+  printf ("%1$*d", i, i); /* { dg-warning "missing" "mixing $ and non-$ formats" } */
+  printf ("%*1$d", i); /* { dg-warning "missing" "mixing $ and non-$ formats" } */
+  scanf ("%1$d%d", ip, ip); /* { dg-warning "missing" "mixing $ and non-$ formats" } */
+  scanf ("%*f%%%1$d%%%2$d", ip, ip);
+  printf ("%2$d", i); /* { dg-warning "operand" "$ number too large" } */
+  printf ("%0$d", i); /* { dg-warning "operand" "$ number too small" } */
+  printf ("%3$d%1$d", i, i, i); /* { dg-warning "before used" "unused $ operand" } */
+  printf ("%2$d%1$d", i, i, i); /* { dg-warning "unused" "unused $ operand" } */
+  vprintf ("%3$d%1$d", va); /* { dg-warning "before used" "unused $ operand" } */
+  scanf ("%2$*d%1$d", ip, ip); /* { dg-warning "operand" "operand number with suppression" } */
+  printf ("%1$d%1$d", i);
+  scanf ("%1$d%1$d", ip); /* { dg-warning "more than once" "multiple use of scanf argument" } */
+}
diff --git a/gcc/testsuite/gcc.dg/format/z-1.c b/gcc/testsuite/gcc.dg/format/z-1.c
new file mode 100644 (file)
index 0000000..4125d54
--- /dev/null
@@ -0,0 +1,31 @@
+/* Test for bugs with %z and %Z formats.  See PRs c/89, c/156, c/376.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+extern int printf (const char *, ...);
+extern int scanf (const char *, ...);
+
+size_t
+foo (void)
+{
+  size_t t;
+  scanf ("%zu", &t); /* { dg-bogus "length|format" "bogus scanf warning" } */
+  return t;
+}
+
+void
+bar (size_t t)
+{
+  printf ("%zu\n", t); /* { dg-bogus "format" "bogus printf warning" } */
+}
+
+/* The %Z printf format is an old GNU libc extension to do the same thing.  */
+
+void
+baz (size_t t)
+{
+  printf ("%Zu\n", t); /* { dg-bogus "format" "bogus printf warning" } */
+}
diff --git a/gcc/testsuite/gcc.dg/formatz-1.c b/gcc/testsuite/gcc.dg/formatz-1.c
deleted file mode 100644 (file)
index 4125d54..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Test for bugs with %z and %Z formats.  See PRs c/89, c/156, c/376.  */
-/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do compile } */
-/* { dg-options "-Wformat" } */
-
-typedef __SIZE_TYPE__ size_t;
-
-extern int printf (const char *, ...);
-extern int scanf (const char *, ...);
-
-size_t
-foo (void)
-{
-  size_t t;
-  scanf ("%zu", &t); /* { dg-bogus "length|format" "bogus scanf warning" } */
-  return t;
-}
-
-void
-bar (size_t t)
-{
-  printf ("%zu\n", t); /* { dg-bogus "format" "bogus printf warning" } */
-}
-
-/* The %Z printf format is an old GNU libc extension to do the same thing.  */
-
-void
-baz (size_t t)
-{
-  printf ("%Zu\n", t); /* { dg-bogus "format" "bogus printf warning" } */
-}