[cfe-commits] [PATCH] Suppress elided variadic macro argument diagnostic with comma pasting extension
Eli Friedman
eli.friedman at gmail.com
Mon Nov 12 14:48:30 PST 2012
Is anyone planning to look at this patch?
-Eli
On Fri, Nov 9, 2012 at 7:01 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> Suppose you have a testcase like the following:
>
> #define NSAssert(condition, desc, ...) \
> SomeComplicatedStuff((desc), ##__VA_ARGS__)
> NSAssert(somecond, somedesc)
>
> We currently print two diagnostics:
>
> <stdin>:3:28: warning: must specify at least one argument for '...'
> parameter of variadic macro [-Wgnu]
> NSAssert(somecond, somedesc)
> ^
> <stdin>:1:9: note: macro 'NSAssert' defined here
> #define NSAssert(condition, desc, ...) \
> ^
> <stdin>:2:32: warning: token pasting of ',' and __VA_ARGS__ is a GNU
> extension [-Wgnu]
> SomeComplicatedStuff((desc), ##__VA_ARGS__)
>
>
> The attached patch suppresses the first diagnostic in certain cases
> where we know we're going to print the second diagnostic. The
> diagnostic is redundant, and it can't be suppressed in the definition
> of the macro because it points at the use of the macro, so we want to
> avoid printing it if possible.
>
> The implementation works by detecting constructs which look like comma
> pasting at the time of the definition of the macro; this information
> is then used when the macro is used. (We can't actually detect
> whether we're using the comma pasting extension until the macro is
> actually used, but we can detecting constructs which will be comma
> pasting if the varargs argument is elided.)
>
> I'm asking for a review because I'm not very familiar with this code.
>
> -Eli
More information about the cfe-commits
mailing list