blob: 2309e98066c60e07d6b2392080228f5140cc37e3 [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
4// In C++, the bitfield promotion from long to int does not occur, unlike C.
5// expected-no-diagnostics
6
7int printf(const char *restrict, ...);
8
9struct bitfields {
10 long a : 2;
11 unsigned long b : 2;
12 long c : 32; // assumes that int is 32 bits
13 unsigned long d : 32; // assumes that int is 32 bits
14} bf;
15
16void bitfield_promotion() {
17 printf("%ld", bf.a);
18 printf("%lu", bf.b);
19 printf("%ld", bf.c);
20 printf("%lu", bf.d);
21}