annotate gcc/testsuite/gcc.dg/format/no-exargs-2.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for warnings for extra format arguments being disabled by
kono
parents:
diff changeset
2 -Wno-format-extra-args. Test which warnings still apply with $
kono
parents:
diff changeset
3 operand numbers. */
kono
parents:
diff changeset
4 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
kono
parents:
diff changeset
5 /* { dg-do compile } */
kono
parents:
diff changeset
6 /* { dg-options "-std=gnu99 -Wformat -Wno-format-extra-args" } */
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 #include "format.h"
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 void
kono
parents:
diff changeset
11 foo (int i, int *ip, va_list va)
kono
parents:
diff changeset
12 {
kono
parents:
diff changeset
13 printf ("%3$d%1$d", i, i, i); /* { dg-warning "before used" "unused $ operand" } */
kono
parents:
diff changeset
14 printf ("%2$d%1$d", i, i, i);
kono
parents:
diff changeset
15 vprintf ("%3$d%1$d", va); /* { dg-warning "before used" "unused $ operand" } */
kono
parents:
diff changeset
16 /* With scanf formats, gaps in the used arguments are allowed only if the
kono
parents:
diff changeset
17 arguments are all pointers. In such a case, should only give the lesser
kono
parents:
diff changeset
18 warning about unused arguments rather than the more serious one about
kono
parents:
diff changeset
19 argument gaps. */
kono
parents:
diff changeset
20 scanf ("%3$d%1$d", ip, ip, ip);
kono
parents:
diff changeset
21 /* If there are non-pointer arguments unused at the end, this is also OK. */
kono
parents:
diff changeset
22 scanf ("%3$d%1$d", ip, ip, ip, i);
kono
parents:
diff changeset
23 scanf ("%3$d%1$d", ip, i, ip); /* { dg-warning "before used" "unused $ scanf non-pointer operand" } */
kono
parents:
diff changeset
24 /* Can't check the arguments in the vscanf case, so should suppose the
kono
parents:
diff changeset
25 lesser problem. */
kono
parents:
diff changeset
26 vscanf ("%3$d%1$d", va);
kono
parents:
diff changeset
27 }