OSDN Git Service

ms format support for mingw.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / format / ms_multattr-3.c
1 /* Test for multiple format_arg attributes.  Test for both branches
2    getting checked.  */
3 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
4 /* { dg-do compile { target { *-*-mingw* } } } */
5 /* { dg-options "-std=gnu99 -Wformat" } */
6
7 #define USE_SYSTEM_FORMATS
8 #include "format.h"
9
10 extern char *ngettext (const char *, const char *, unsigned long int)
11      __attribute__((__format_arg__(1))) __attribute__((__format_arg__(2)));
12
13 void
14 foo (long l, int nfoo)
15 {
16   printf (ngettext ("%d foo", "%d foos", nfoo), nfoo);
17   printf (ngettext ("%d foo", "%d foos", l), l); /* { dg-warning "int" "wrong type in conditional expr" } */
18   printf (ngettext ("%d foo", "%ld foos", l), l); /* { dg-warning "int" "wrong type in conditional expr" } */
19   printf (ngettext ("%ld foo", "%d foos", l), l); /* { dg-warning "int" "wrong type in conditional expr" } */
20   /* Should allow one case to have extra arguments.  */
21   printf (ngettext ("1 foo", "%d foos", nfoo), nfoo);
22   printf (ngettext ("1 foo", "many foos", nfoo), nfoo); /* { dg-warning "too many" "too many args in all branches" } */
23   printf (ngettext ("", "%d foos", nfoo), nfoo);
24   printf (ngettext ("1 foo", (nfoo > 0) ? "%d foos" : "no foos", nfoo), nfoo);
25   printf (ngettext ("%d foo", (nfoo > 0) ? "%d foos" : "no foos", nfoo), nfoo);
26   printf (ngettext ("%ld foo", (nfoo > 0) ? "%d foos" : "no foos", nfoo), nfoo); /* { dg-warning "long int" "wrong type" } */
27   printf (ngettext ("%d foo", (nfoo > 0) ? "%ld foos" : "no foos", nfoo), nfoo); /* { dg-warning "long int" "wrong type" } */
28   printf (ngettext ("%d foo", (nfoo > 0) ? "%d foos" : "%ld foos", nfoo), nfoo); /* { dg-warning "long int" "wrong type" } */
29 }