[clang] [C23] Add __builtin_c23_va_start (PR #131166)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 13 10:01:48 PDT 2025


================
@@ -4864,14 +4877,22 @@ bool Sema::BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) {
     return true;
 
   // Verify that the second argument to the builtin is the last argument of the
-  // current function or method. In C23 mode, if the second argument is an
-  // integer constant expression with value 0, then we don't bother with this
-  // check.
+  // current function or method. In C23 mode and the call is not to
+  // __builtin_c23_va_start, if the second argument is an integer constant
+  // expression with value 0, then we don't bother with this check. For
+  // __builtin_c23_va_start, we only perform the check for the second argument
+  // being the last argument to the current function if there is a second
+  // argument present.
+  if (BuiltinID == Builtin::BI__builtin_c23_va_start &&
+      TheCall->getNumArgs() < 2)
+    return false;
+
   bool SecondArgIsLastNamedArgument = false;
----------------
AaronBallman wrote:

Sure, I can move it.

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


More information about the cfe-commits mailing list