1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2
3 int printf(const char *, ...);
4
5 const char* f(const char *s) __attribute__((format_arg(1)));
6
7 const char *h(const char *msg1, const char *msg2)
8 __attribute__((__format_arg__(1))) __attribute__((__format_arg__(2)));
9
g(const char * s)10 void g(const char *s) {
11 printf("%d", 123);
12 printf("%d %d", 123); // expected-warning{{more '%' conversions than data arguments}}
13
14 printf(f("%d"), 123);
15 printf(f("%d %d"), 123); // expected-warning{{more '%' conversions than data arguments}}
16
17 printf(h(
18 "", // expected-warning {{format string is empty}}
19 "" // expected-warning {{format string is empty}}
20 ), 123);
21 printf(h(
22 "%d",
23 "" // expected-warning {{format string is empty}}
24 ), 123);
25 printf(h(
26 "", // expected-warning {{format string is empty}}
27 "%d"
28 ), 123);
29 printf(h("%d", "%d"), 123);
30 }
31