OSDN Git Service

2010-05-09 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / format / no-exargs-2.c
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 } */
6 /* { dg-options "-std=gnu99 -Wformat -Wno-format-extra-args" } */
7
8 #include "format.h"
9
10 void
11 foo (int i, int *ip, va_list va)
12 {
13   printf ("%3$d%1$d", i, i, i); /* { dg-warning "before used" "unused $ operand" } */
14   printf ("%2$d%1$d", i, i, i);
15   vprintf ("%3$d%1$d", va); /* { dg-warning "before used" "unused $ operand" } */
16   /* With scanf formats, gaps in the used arguments are allowed only if the
17      arguments are all pointers.  In such a case, should only give the lesser
18      warning about unused arguments rather than the more serious one about
19      argument gaps.  */
20   scanf ("%3$d%1$d", ip, ip, ip);
21   /* If there are non-pointer arguments unused at the end, this is also OK.  */
22   scanf ("%3$d%1$d", ip, ip, ip, i);
23   scanf ("%3$d%1$d", ip, i, ip); /* { dg-warning "before used" "unused $ scanf non-pointer operand" } */
24   /* Can't check the arguments in the vscanf case, so should suppose the
25      lesser problem.  */
26   vscanf ("%3$d%1$d", va);
27 }