brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 66bf1de Raw
31 lines · cpp
1// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wformat -Wformat-signedness %s2// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -verify -Wformat -Wformat-signedness %s3 4// Verify that -Wformat-signedness alone (without -Wformat) trigger the5// warnings. Note in gcc this will not trigger the signedness warnings as6// -Wformat is default off in gcc.7// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wformat-signedness %s8// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -verify -Wformat-signedness %s9 10// Verify that -Wformat-signedness warnings are not reported with only -Wformat11// (gcc compat).12// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -Wformat -verify=okay %s13 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 %s16// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -Wno-format -Wformat-signedness -verify=okay %s17// okay-no-diagnostics18 19// Ignore 'GCC requires a function with the 'format' attribute to be variadic'.20#pragma GCC diagnostic ignored "-Wgcc-compat"21namespace GH161075 {22template <typename... Args>23void format(const char *fmt, Args &&...args)24    __attribute__((format(printf, 1, 2)));25 26void 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 GH16107531