| 1 |
// RUN: %clang_cc1 -verify %s |
| 2 |
// expected-no-diagnostics |
| 3 |
|
| 4 |
// A prvalue for an integral bit-field can be converted to a prvalue of type |
| 5 |
// int if int can represent all the values of the bit-field |
| 6 |
struct X { long long e : 1; }; |
| 7 |
static_assert(sizeof(+X().e) == sizeof(int), ""); |
| 8 |
static_assert(sizeof(X().e + 1) == sizeof(int), ""); |
| 9 |
static_assert(sizeof(true ? X().e : 0) == sizeof(int), ""); |
| 10 |
|
| 11 |
enum E : long long { a = __LONG_LONG_MAX__ }; |
| 12 |
static_assert(sizeof(E{}) == sizeof(long long), ""); |
| 13 |
|
| 14 |
// If the bit-field has an enumerated type, it is treated as any other value of |
| 15 |
// that [enumerated] type for promotion purposes. |
| 16 |
struct Y { E e : 1; }; |
| 17 |
static_assert(sizeof(+Y().e) == sizeof(long long), ""); |
| 18 |
static_assert(sizeof(Y().e + 1) == sizeof(long long), ""); |
| 19 |
static_assert(sizeof(true ? Y().e : 0) == sizeof(long long), ""); |