Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -7102,6 +7102,21 @@ case BuiltinType::Int128: case BuiltinType::UInt128: return 7 + (getIntWidth(Int128Ty) << 3); + + // "The ranks of char8_t, char16_t, char32_t, and wchar_t equal the ranks of + // their underlying types" [c++20 conv.rank] + case BuiltinType::Char8: + return getIntegerRank(CharTy.getTypePtr()); + case BuiltinType::Char16: + return getIntegerRank( + getFromTargetType(Target->getChar16Type()).getTypePtr()); + case BuiltinType::Char32: + return getIntegerRank( + getFromTargetType(Target->getChar32Type()).getTypePtr()); + case BuiltinType::WChar_S: + case BuiltinType::WChar_U: + return getIntegerRank( + getFromTargetType(Target->getWCharType()).getTypePtr()); } } Index: clang/test/SemaCXX/vector-bool.cpp =================================================================== --- clang/test/SemaCXX/vector-bool.cpp +++ clang/test/SemaCXX/vector-bool.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-linux-pc -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++17 +// RUN: %clang_cc1 -triple x86_64-linux-pc -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++20 // Note that this test depends on the size of long-long to be different from // int, so it specifies a triple. @@ -90,3 +90,15 @@ foo(eight_bools.w); // expected-error@90 {{illegal vector component name ''w''}} foo(eight_bools.wyx); // expected-error@91 {{illegal vector component name ''wyx''}} } + +// Don't crash due to missing integer ranks. +char8_t v1 __attribute__((vector_size(16))); +char16_t v2 __attribute__((vector_size(16))); +char32_t v3 __attribute__((vector_size(16))); +wchar_t v4 __attribute__((vector_size(16))); +void triggerIntegerRankCheck() { + auto b1 = (v1 >= 0x12); + auto b2 = (v2 >= 0x12); + auto b3 = (v3 >= 0x12); + auto b4 = (v4 >= 0x12); +}