return false;
// We can perform an integral promotion to the underlying type of the enum,
- // even if that's not the promoted type.
+ // even if that's not the promoted type. Note that the check for promoting
+ // the underlying type is based on the type alone, and does not consider
+ // the bitfield-ness of the actual source expression.
if (FromEnumType->getDecl()->isFixed()) {
QualType Underlying = FromEnumType->getDecl()->getIntegerType();
return Context.hasSameUnqualifiedType(Underlying, ToType) ||
- IsIntegralPromotion(From, Underlying, ToType);
+ IsIntegralPromotion(nullptr, Underlying, ToType);
}
// We have already pre-calculated the promotion type, so this is trivial.
A::B : C;
};
}
+
+enum WithUnderlying : unsigned { wu_value };
+struct WithUnderlyingBitfield {
+ WithUnderlying wu : 3;
+} wu = { wu_value };
+int want_unsigned(unsigned);
+int want_unsigned(int) = delete;
+int check_enum_bitfield_promotes_correctly = want_unsigned(wu.wu);