diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/format/xopen-3.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/format/xopen-3.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/format/xopen-3.c b/gcc/testsuite/gcc.dg/format/xopen-3.c new file mode 100644 index 000000000..5f78d77c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/xopen-3.c @@ -0,0 +1,15 @@ +/* Test for warnings for $ operand numbers after ordinary formats. + Bug c/15444 from james-gcc-bugzilla-501qll3d at and dot org. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wformat" } */ + +#include "format.h" + +void +foo (int i) +{ + printf ("%d%2$d", i); /* { dg-warning "used after format" "mixing $ and non-$ formats" } */ + printf ("%d%*1$d", i, i); /* { dg-warning "used after format" "mixing $ and non-$ formats" } */ + printf ("%d%.*1$d", i, i); /* { dg-warning "used after format" "mixing $ and non-$ formats" } */ +} |