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