Right now -Wcomma is too strict IMO, we shouldn't warn about expressions that return void.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I thought the intention of -Wcomma was to warn on practically all non-macro uses of the comma operator. I know it's silly to cast void to void, but I seem to recall that this was an intentional style-ish warning like -Wparentheses, which encourages if ((x = y)) for intentional assignments in ifs.
I thought void-returning functions were supposed to be allowed based on the description in https://reviews.llvm.org/D3976 , but later in that discussion the definition was changed to instead allow almost nothing.
Reid is correct, the whitelisted expressions was greatly reduced during code review so only casts to void would disable the warning. While the last review did not have the description updated to reflect this, the committed code does have an accurate description. What is the reason to exclude void expressions now? For the function case, it is more consistent to warn on all function calls since we can't determine if a function returns void just by looking at the call site.
Ah, I see, so this is more of a stylistic warning rather than "suspicious" use one.
We've had an issue with -Wcomma adoption internally and have thought that this was a bug.