[clang] [clang] Report Diagnostic when builtin vector has negative size (PR #166055)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 3 08:47:53 PST 2025


================
@@ -8285,10 +8285,20 @@ static void HandleVectorSizeAttr(QualType &CurType, const ParsedAttr &Attr,
 
   Expr *SizeExpr = Attr.getArgAsExpr(0);
   QualType T = S.BuildVectorType(CurType, SizeExpr, Attr.getLoc());
-  if (!T.isNull())
-    CurType = T;
-  else
+  if (T.isNull()) {
+    Attr.setInvalid();
+    return;
+  }
+
+  std::optional<llvm::APSInt> VecSize =
----------------
AaronBallman wrote:

I think this logic should live in `BuildVectorType()` instead, near where we emit `err_attribute_invalid_size`.

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


More information about the cfe-commits mailing list