From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gcc.dg/format/strfmon-1.c | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/format/strfmon-1.c (limited to 'gcc/testsuite/gcc.dg/format/strfmon-1.c') diff --git a/gcc/testsuite/gcc.dg/format/strfmon-1.c b/gcc/testsuite/gcc.dg/format/strfmon-1.c new file mode 100644 index 000000000..934242a23 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/strfmon-1.c @@ -0,0 +1,63 @@ +/* Test for strfmon format checking. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wformat" } */ + +#include "format.h" + +void +foo (char *s, size_t m, double d, long double ld) +{ + /* Examples of valid formats from Austin Group draft 7. */ + 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); + strfmon (s, m, "%-14#5.4n", d); + strfmon (s, m, "%14#5.4n", 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); + strfmon (s, m, "%-14#5.4Li", ld); + strfmon (s, m, "%14#5.4Li", 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 "matching" "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" } */ +} -- cgit v1.2.3