diff options
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 6 | ||||
| -rw-r--r-- | clang/test/SemaCXX/enum-bitfield.cpp | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index fbf110b321e..cf84f23baf4 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1752,11 +1752,13 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) { 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. diff --git a/clang/test/SemaCXX/enum-bitfield.cpp b/clang/test/SemaCXX/enum-bitfield.cpp index ec849b79a74..676ae44b37f 100644 --- a/clang/test/SemaCXX/enum-bitfield.cpp +++ b/clang/test/SemaCXX/enum-bitfield.cpp @@ -28,3 +28,11 @@ struct D { 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); |

