[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / clang / test / Sema / attr-format_arg.c
blobe041c5acbffa5682ec3c9c4909c10f9a998e769c
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 int printf(const char *, ...);
5 const char* f(const char *s) __attribute__((format_arg(1)));
7 const char *h(const char *msg1, const char *msg2)
8 __attribute__((__format_arg__(1))) __attribute__((__format_arg__(2)));
10 void g(const char *s) {
11 printf("%d", 123);
12 printf("%d %d", 123); // expected-warning{{more '%' conversions than data arguments}}
14 printf(f("%d"), 123);
15 printf(f("%d %d"), 123); // expected-warning{{more '%' conversions than data arguments}}
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);