diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2832,7 +2832,7 @@ // All integrals and enums are unique. if (Ty->isIntegralOrEnumerationType()) { // Except _BitInt types that have padding bits. - if (const auto *BIT = dyn_cast(Ty)) + if (const auto *BIT = Ty->getAs()) return getTypeSize(BIT) == BIT->getNumBits(); return true; diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp --- a/clang/test/SemaCXX/type-traits.cpp +++ b/clang/test/SemaCXX/type-traits.cpp @@ -2970,6 +2970,12 @@ bool b = __has_unique_object_representations(T); }; +static_assert(!has_unique_object_representations<_BitInt(7)>::value, "BitInt:"); +static_assert(has_unique_object_representations<_BitInt(8)>::value, "BitInt:"); +static_assert(!has_unique_object_representations<_BitInt(127)>::value, "BitInt:"); +static_assert(has_unique_object_representations<_BitInt(128)>::value, "BitInt:"); + + namespace PR46209 { // Foo has both a trivial assignment operator and a non-trivial one. struct Foo {