[clang] [Clang][diagnostics] Improve the diagnostics for chained comparisons (PR #129285)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 28 10:55:02 PST 2025
================
@@ -85,7 +85,7 @@ void f(int x, int y, int z) {
if ((a<y) != -1) {}// expected-warning {{comparison of constant -1 with boolean expression is always true}}
if ((a<y) == z) {} // no warning
- if (a>y<z) {} // expected-error {{comparisons like 'X<=Y<=Z' don't have their mathematical meaning}}
+ if (a>y<z) {} // expected-error {{comparisons like 'a > y < z' don't have their mathematical meaning}}
----------------
erichkeane wrote:
Hmm.... @AaronBallman will probably have to comment here, but I'm not sure this is better? The point of `comparisons like` here was to simplify the diagnostics to something that is `like` what is there, but not actually.
This patch ends up giving us really awful warning/diagnostics in the case where these are more than simple variables, as its just dumping the entire expression. So I don't know if I like this patch.
https://github.com/llvm/llvm-project/pull/129285
More information about the cfe-commits
mailing list