<div dir="ltr">Arthur,<div><br></div><div>I have included a note that includes a fix-it to silence the warning.  This seems to be the best way to handle this as the compiler cannot infer the safe use of the comma operator in your example.  Casts to void will be silence -Wcomma.</div>
<div><br></div><div>Richard</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 30, 2014 at 10:22 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">-Wcomma currently triggers 6 times in your example.  The BinaryOperator's for the these comma operators does not show up in the AST dump.  I will take a closer look when I have the chance.<div>
<br></div>
<div>Assert macros will not be a problem as this warning will not trigger inside macros.<div><div class="h5"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 30, 2014 at 9:26 PM, Arthur O'Dwyer <span dir="ltr"><<a href="mailto:arthur.j.odwyer@gmail.com" target="_blank">arthur.j.odwyer@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The name "-Wcomma" is pretty generic; I wonder if you could give it a<br>
more specific name. (But then again, "-Wquestionable-comma-usage" or<br>
whatever isn't any more helpful.)<br>
<br>
Please make sure the warning doesn't trigger on parameter-pack<br>
expansions that are being used for their cardinality; for example,<br>
this case from MPL11:<br>
<br>
    template <bool ...> struct bool_seq;<br>
    template <typename ...xs> using and_ =<br>
      std::is_same< bool_seq<xs::value...>, bool_seq<(xs::value, true)...> >;<br>
<br>
    static_assert(and_<std::true_type, std::true_type,<br>
std::true_type>::value == true, "");<br>
    static_assert(and_<std::true_type, std::false_type,<br>
std::true_type>::value == false, "");<br>
<br>
The expression "(xs::value, true)" might seem silly, but because it's<br>
followed by "..." it's actually sensible.<br>
<br>
I feel like there are other cases involving assert-esque macros that<br>
would be problematic, but I can't think of any good examples off the<br>
top of my head.<br>
<br>
HTH,<br>
Arthur<br>
<div><div><br>
<br>
On Fri, May 30, 2014 at 8:03 PM, Richard Trieu <<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>> wrote:<br>
> -Wcomma emits a warning when there is a questionable use of the comma operator.  It does this by only allowing certain expressions on the LHS of the comma operator, with all other expressions giving a warning.  The current whitelisted expressions are increments, decrements, assignments, compound assignments, overloaded versions of these operators, and void returning functions.  Some examples of code that will be detected:<br>


><br>
>   int foo();<br>
>   if (foo(), 5) {} // should be "=="<br>
>   cout << "foo is " , foo();  // should be "<<"<br>
><br>
>   void bar(int);<br>
>   void bar(int, int);<br>
>   bar((foo(), foo()));  // Too many parens, calls the one argument function<br>
><br>
> <a href="http://reviews.llvm.org/D3976" target="_blank">http://reviews.llvm.org/D3976</a><br>
><br>
> Files:<br>
>   include/clang/Basic/DiagnosticSemaKinds.td<br>
>   lib/Sema/SemaExpr.cpp<br>
>   test/SemaCXX/warn-comma-operator.cpp<br>
><br>
</div></div>> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
><br>
</blockquote></div><br></div></div></div></div></div>
</blockquote></div><br></div>