| 1 |
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wformat -Wformat-signedness %s |
| 2 |
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -verify -Wformat -Wformat-signedness %s |
| 3 |
|
| 4 |
// Verify that -Wformat-signedness alone (without -Wformat) trigger the |
| 5 |
// warnings. Note in gcc this will not trigger the signedness warnings as |
| 6 |
// -Wformat is default off in gcc. |
| 7 |
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wformat-signedness %s |
| 8 |
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -verify -Wformat-signedness %s |
| 9 |
|
| 10 |
// Verify that -Wformat-signedness warnings are not reported with only -Wformat |
| 11 |
// (gcc compat). |
| 12 |
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -Wformat -verify=okay %s |
| 13 |
|
| 14 |
// Verify that -Wformat-signedness with -Wno-format are not reported (gcc compat). |
| 15 |
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -Wformat-signedness -Wno-format -verify=okay %s |
| 16 |
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -Wno-format -Wformat-signedness -verify=okay %s |
| 17 |
// okay-no-diagnostics |
| 18 |
|
| 19 |
// Ignore 'GCC requires a function with the 'format' attribute to be variadic'. |
| 20 |
#pragma GCC diagnostic ignored "-Wgcc-compat" |
| 21 |
namespace GH161075 { |
| 22 |
template <typename... Args> |
| 23 |
void format(const char *fmt, Args &&...args) |
| 24 |
__attribute__((format(printf, 1, 2))); |
| 25 |
|
| 26 |
void do_format() { |
| 27 |
bool b = false; |
| 28 |
format("%hhi %hhu %hi %hu %i %u", b, b, b, b, b, b); // expected-warning {{format specifies type 'unsigned char' but the argument has type 'bool', which differs in signedness}} |
| 29 |
} |
| 30 |
} // namespace GH161075 |