diff options
author | Joseph Myers <jsm28@cam.ac.uk> | 2001-01-06 18:47:19 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2001-01-06 18:47:19 +0000 |
commit | cd5662732a9ce840e9276d18b080cd38ec1d66a5 (patch) | |
tree | 3fde55ebae06b1a7ecee2eaac788cb5c9478910f /gcc/testsuite/gcc.dg/format/ext-1.c | |
parent | fa6f74f611d8d35e3d07ecf6fc40e7e07ff6792a (diff) | |
download | gcc-cd5662732a9ce840e9276d18b080cd38ec1d66a5.zip gcc-cd5662732a9ce840e9276d18b080cd38ec1d66a5.tar.gz gcc-cd5662732a9ce840e9276d18b080cd38ec1d66a5.tar.bz2 |
format.exp: New file.
* 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
Diffstat (limited to 'gcc/testsuite/gcc.dg/format/ext-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/format/ext-1.c | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/format/ext-1.c b/gcc/testsuite/gcc.dg/format/ext-1.c new file mode 100644 index 0000000..238a478 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/ext-1.c @@ -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" } */ +} |