| 1 |
// RUN: %clang_cc1 -triple x86_64-apple-darwin9.0 -fsyntax-only -verify -Wno-format -Wformat-type-confusion %s |
| 2 |
|
| 3 |
__attribute__((format(__printf__, 1, 2))) |
| 4 |
int printf(const char *msg, ...); |
| 5 |
|
| 6 |
#define FMT "%hd %hu %d %u %hhd %hhu %c" |
| 7 |
|
| 8 |
int main(void) { |
| 9 |
_Bool b = 0; |
| 10 |
printf(FMT, |
| 11 |
b, // expected-warning {{format specifies type 'short' but the argument has type '_Bool'}} |
| 12 |
b, // expected-warning {{format specifies type 'unsigned short' but the argument has type '_Bool'}} |
| 13 |
b, b, b, b, b); |
| 14 |
|
| 15 |
unsigned char uc = 0; |
| 16 |
printf(FMT, |
| 17 |
uc, // expected-warning {{format specifies type 'short' but the argument has type 'unsigned char'}} |
| 18 |
uc, // expected-warning {{format specifies type 'unsigned short' but the argument has type 'unsigned char'}} |
| 19 |
uc, uc, uc, uc, uc); |
| 20 |
|
| 21 |
signed char sc = 0; |
| 22 |
printf(FMT, |
| 23 |
sc, // expected-warning {{format specifies type 'short' but the argument has type 'signed char'}} |
| 24 |
sc, // expected-warning {{format specifies type 'unsigned short' but the argument has type 'signed char'}} |
| 25 |
sc, sc, sc, sc, sc); |
| 26 |
} |