blob: cbe00e7510dd80ce92f6a04f8ec1860538a4c319 [file] [log] [blame]
Aaron Ballman94d2d092018-12-18 15:54:38 +00001// 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
3
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 bits
10 unsigned long d : 32; // assumes that int is 32 bits
11} bf;
12
13void bitfield_promotion() {
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}