[clang] [Clang] [Sema] Reject non-power-of-2 `_BitInt` matrix element types (PR #117487)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 25 03:31:30 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;
----------------
Sirraide wrote:

Ah yeah, I always forget that you can do this.

https://github.com/llvm/llvm-project/pull/117487


More information about the cfe-commits mailing list