PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / format / ms_no-exargs-2.c
blob654241ddff475184744e66fd4d1251d51902a153
1 /* Test for warnings for extra format arguments being disabled by
2 -Wno-format-extra-args. Test which warnings still apply with $
3 operand numbers. */
4 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
5 /* { dg-do compile { target { *-*-mingw* } } } */
6 /* { dg-options "-std=gnu99 -Wformat -Wno-format-extra-args" } */
8 #define USE_SYSTEM_FORMATS
9 #include "format.h"
11 void
12 foo (int i, int *ip, va_list va)
14 printf ("%3$d%1$d", i, i, i); /* { dg-warning "before used" "unused $ operand" } */
15 printf ("%2$d%1$d", i, i, i);
16 vprintf ("%3$d%1$d", va); /* { dg-warning "before used" "unused $ operand" } */
17 /* With scanf formats, gaps in the used arguments are allowed only if the
18 arguments are all pointers. In such a case, should only give the lesser
19 warning about unused arguments rather than the more serious one about
20 argument gaps. */
21 scanf ("%3$d%1$d", ip, ip, ip);
22 /* If there are non-pointer arguments unused at the end, this is also OK. */
23 scanf ("%3$d%1$d", ip, ip, ip, i);
24 scanf ("%3$d%1$d", ip, i, ip); /* { dg-warning "before used" "unused $ scanf non-pointer operand" } */
25 /* Can't check the arguments in the vscanf case, so should suppose the
26 lesser problem. */
27 vscanf ("%3$d%1$d", va);