[cfe-dev] rfc: winnt.h's UNREFERENCED_PARAMETER() vs clang's -Wunused-value

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 12 16:11:46 PDT 2015


On Mon, Oct 12, 2015 at 3:04 PM, Nico Weber via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> On Mon, Oct 12, 2015 at 3:02 PM, David Majnemer <david.majnemer at gmail.com>
> wrote:
>
>> On Mon, Oct 12, 2015 at 2:18 PM, Reid Kleckner via cfe-dev <
>> cfe-dev at lists.llvm.org> wrote:
>>
>>> I'd really rather not do 2. Fighting with MSVC CRT headers over va_start
>>> has been pretty awkward. Users have reported issues with our header
>>> override fails. I'd rather not start fighting with winnt.h.
>>>
>>> I'm OK with 3, but I'm desensitized to having to do this kind of pattern
>>> matching for __uuidof, etc. Maybe we should wait for another +1. :)
>>>
>>
>> A +1 from me for option #3 as well.  I'd feel more comfortable doing #2
>> if it was for correctness (along the lines of our  va_start/va_arg hack).
>>
>> On what basis does MSVC decide that UNREFERENCED_PARAMETER should silence
>> an unused parameter?  IIRC, it expands to wrapping it's argument in
>> parenthesis.  Could we teach clang to do the same?  Sounds like it could be
>> a more general fix.
>>
>
> That sounds like a really good idea to me – teach sema that "(x);" has the
> same meaning as "(void)x;".
>

Hold on a moment.

`(x);` certainly seems like it should silence an "unreferenced parameter"
warning (which is what this macro is for in MSVC), but it seems much less
reasonable for it to suppress an "unused value" warning (which is the
warning we're getting with Clang). This is not an idiom we should encourage
for expressing "I am deliberately discarding this value", so I would prefer
limiting this to the case where the parens come from a macro named
UNREFERENCED_PARAMETER.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151012/7eeee1bd/attachment.html>


More information about the cfe-dev mailing list