aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/format
diff options
context:
space:
mode:
authorJoseph Myers <jsm@polyomino.org.uk>2004-05-15 01:44:02 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2004-05-15 01:44:02 +0100
commite9a757769b395ef082be82777e68bfe8a8a79f90 (patch)
tree5a17c82d4a869e1134d2e5c2dbe9cf8ab06adb7d /gcc/testsuite/gcc.dg/format
parent5c3be6fdb01517c31d6a64e675bc9b52d3d7633b (diff)
downloadgcc-e9a757769b395ef082be82777e68bfe8a8a79f90.zip
gcc-e9a757769b395ef082be82777e68bfe8a8a79f90.tar.gz
gcc-e9a757769b395ef082be82777e68bfe8a8a79f90.tar.bz2
re PR c/15444 (Bad warning message in printf format checking)
PR c/15444 * c-format.c (avoid_dollar_number): New function. (check_format_info_main): Call avoid_dollar_number when operand numbers might occur but has_operand_number == 0. testsuite: * gcc.dg/format/xopen-1.c: Adjust expected message. * gcc.dg/format/xopen-3.c: New test. From-SVN: r81871
Diffstat (limited to 'gcc/testsuite/gcc.dg/format')
-rw-r--r--gcc/testsuite/gcc.dg/format/xopen-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/format/xopen-3.c15
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/format/xopen-1.c b/gcc/testsuite/gcc.dg/format/xopen-1.c
index 934dcb1..1462a2c 100644
--- a/gcc/testsuite/gcc.dg/format/xopen-1.c
+++ b/gcc/testsuite/gcc.dg/format/xopen-1.c
@@ -95,7 +95,7 @@ foo (int i, unsigned int u, wint_t lc, wchar_t *ls, int *ip, double d,
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 ("%d%2$d", i); /* { dg-warning "used after format" "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" } */
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 0000000..5f78d77
--- /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" } */
+}