[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / clang / test / Sema / format-strings-bitfield-promotion.c
blob42c851cf93614c4ca307e6551564bc5a088d3c6e
1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fsyntax-only -verify %s
4 int printf(const char *restrict, ...);
6 struct bitfields {
7 long a : 2;
8 unsigned long b : 2;
9 long c : 32; // assumes that int is 32 bits
10 unsigned long d : 32; // assumes that int is 32 bits
11 } bf;
13 void bitfield_promotion(void) {
14 printf("%ld", bf.a); // expected-warning {{format specifies type 'long' but the argument has type 'int'}}
15 printf("%lu", bf.b); // expected-warning {{format specifies type 'unsigned long' but the argument has type 'int'}}
16 printf("%ld", bf.c); // expected-warning {{format specifies type 'long' but the argument has type 'int'}}
17 printf("%lu", bf.d); // expected-warning {{format specifies type 'unsigned long' but the argument has type 'unsigned int'}}