[PATCH] D13643: [Sema] Warn on ternary comparison
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 13 07:04:10 PDT 2015
aaron.ballman added a comment.
Should there be an exception to this diagnostic for code involving Boolean values? e.g.,
void f(bool a, bool b, bool c) {
if (a == b == c)
;
}
At the very least, it seems like this should also follow GCC's behavior and suggest parenthesis directly.
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:5865
@@ -5864,1 +5864,3 @@
+def warn_ternary_comparison : Warning<"ternary comparisons do not work "
+ "as expected">,
----------------
This diagnostic somewhat implies that ?: does not work as expected. I prefer GCC's wording for this:
"comparisons like 'X<=Y<=Z' do not have their mathematical meaning"
However, I would love it if we could do one step better and use the same operators the user wrote, if reasonable. ;-)
http://reviews.llvm.org/D13643
More information about the cfe-commits
mailing list