Re: [RFC PATCH] pre-process: add __VA_OPT__ support

Al Viro <[email protected]> Wed, 25 Feb 2026 07:27:31 +0000
Newsgroups org.kernel.vger.linux-sparse
Message-ID <20260225072731.GA3093958@ZenIV>
On Wed, Feb 25, 2026 at 06:40:03AM +0000, Al Viro wrote:
> On Tue, Feb 24, 2026 at 09:29:50PM -0800, Eric Zhang wrote:
> > Add __VA_OPT__ support (C23 6.10.5) including some tests.
> > 
> > At expansion time, substitute() checks whether the variadic
> > argument is empty: if so, skip the region between the markers;
> > otherwise, process the enclosed tokens normally.
> > 
> > Signed-off-by: Eric Zhang <[email protected]>
> > ---
> > Discussed this with Chris during lunch yesterday and got curious
> > about the problem, so made a few attempts.  Introducing
> > TOKEN_VA_OPT_START/END feels a bit like an anti-pattern, but I
> > couldn't find a cleaner way to handle it without new token types.
> > Happy to hear suggestions.
> 
> Your variant will break with __VA_OPT__ following #.  It won't do the
> right thing with ## either, AFAICS, in case when __VA_OPT__ token list
> is empty.

Another problem is that having no __VA_ARGS__ in the body should *not*
be treated as "vararg is empty" - if there's a __VA_OPT__ in the body,
you must expand the vararg, no matter what.