1 /* Test for multiple format_arg attributes. Test for both branches
3 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
4 /* { dg-do compile { target { *-*-mingw* } } } */
5 /* { dg-options "-std=gnu99 -Wformat" } */
7 #define USE_SYSTEM_FORMATS
10 extern char *ngettext (const char *, const char *, unsigned long int)
11 __attribute__((__format_arg__(1))) __attribute__((__format_arg__(2)));
14 foo (long l
, int nfoo
)
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" } */