19 lines · c
1// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s2// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fsyntax-only -verify %s3 4int printf(const char *restrict, ...);5 6struct bitfields {7 long a : 2;8 unsigned long b : 2;9 long c : 32; // assumes that int is 32 bits10 unsigned long d : 32; // assumes that int is 32 bits11} bf;12 13void 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'}}18}19