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

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


================
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c23 -fsyntax-only -ffreestanding -verify=expected,both %s -triple i386-pc-unknown
+// RUN: %clang_cc1 -std=c23 -fsyntax-only -ffreestanding -verify=expected,both %s -triple x86_64-apple-darwin9
+// RUN: %clang_cc1 -std=c23 -fsyntax-only -ffreestanding -fms-compatibility -verify=expected,both %s -triple x86_64-pc-win32
+// RUN: %clang_cc1 -std=c17 -fsyntax-only -ffreestanding -verify=both,pre-c23 %s
+
+void foo(int x, int y, ...) {
+  __builtin_va_list list;
+  __builtin_c23_va_start();           // pre-c23-error {{use of unknown builtin '__builtin_c23_va_start'}} \
+                                         expected-error{{too few arguments to function call, expected 1, have 0}}
+  // Note, the unknown builtin diagnostic is only issued once per function,
+  // which is why the rest of the lines do not get the same diagonstic.
+  __builtin_c23_va_start(list);       // ok
+  __builtin_c23_va_start(list, 0);    // expected-warning {{second argument to 'va_start' is not the last named parameter}}
----------------
AaronBallman wrote:

No issue from me with rewording it; that would be a Good First Issue for someone if you wanted to file an issue for it.

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


More information about the cfe-commits mailing list