This implements WG14 N2975 relaxing requirements for va_start (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2975.pdf), which does two things:
- Allows the declaration of a variadic function without any named arguments. e.g., void f(...) is now valid, as in C++.
- Modified the signature of the va_start macro to be a variadic macro that accepts one or more arguments; the second (and later) arguments are not expanded or evaluated.
I followed the GCC implementation in terms of not modifying the behavior of __builtin_va_start (it still requires exactly two arguments), but this approach has led to several QoI issues that I've documented with FIXME comments in the test. Specifically, the requirement that we do not evaluate *or expand* the second and later arguments means it's no longer possible to issue diagnostics for compatibility with older C versions and C++. I am reaching out to folks in WG14 to see if we can get an NB comment to address these concerns (the US comment period has already closed, so I cannot file the comment myself), so the diagnostic behavior may change in the future.
I took this opportunity to add some documentation for all the related builtins in this area, since there was no documentation for them yet.
Yeah, i really think there should be some king of diagnostic here.
Maybe __builtin_va_start could take an arbitrary number of arguments and diagnose for more that 2 args or if the second arg is not valid?
is it a matter of being compatible with gcc? do we need to?