[clang] [Clang] [Sema] Reject non-power-of-2 `_BitInt` matrix element types (PR #117487)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 25 01:49:57 PST 2024
================
@@ -2312,6 +2312,18 @@ QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM,
return T;
}
+bool CheckBitIntElementType(Sema &S, SourceLocation AttrLoc,
+ const BitIntType *BIT, bool ForMatrixType = false) {
+ // Only support _BitInt elements with byte-sized power of 2 NumBits.
+ unsigned NumBits = BIT->getNumBits();
+ if (!llvm::isPowerOf2_32(NumBits) || NumBits < 8) {
+ S.Diag(AttrLoc, diag::err_attribute_invalid_bitint_vector_type)
+ << ForMatrixType << (NumBits < 8);
+ return true;
----------------
Fznamznon wrote:
AFAIK you can do
```suggestion
return S.Diag(AttrLoc, diag::err_attribute_invalid_bitint_vector_type)
<< ForMatrixType << (NumBits < 8);
```
https://github.com/llvm/llvm-project/pull/117487
More information about the cfe-commits
mailing list