[clang] [clang][Sema] Warn consecutive builtin comparisons in an expression (PR #92200)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri May 17 04:18:08 PDT 2024
================
@@ -215,3 +215,10 @@ namespace PR20735 {
// fix-it:"{{.*}}":{[[@LINE-9]]:20-[[@LINE-9]]:20}:")"
}
}
+
+void consecutive_builtin_compare(int x, int y, int z) {
+ (void)(x < y < z); // expected-warning {{comparisons like 'X<=Y<=Z' don't have their mathematical meaning}}
+ (void)(x < y > z); // expected-warning {{comparisons like 'X<=Y<=Z' don't have their mathematical meaning}}
+ (void)(x < y <= z); // expected-warning {{comparisons like 'X<=Y<=Z' don't have their mathematical meaning}}
+ (void)(x <= y > z); // expected-warning {{comparisons like 'X<=Y<=Z' don't have their mathematical meaning}}
----------------
AaronBallman wrote:
> I don't have the capacity to further make clang diagnose case 2 but not case 3.
> I added a TODO note at the bottom of the test lines for now.
SGTM!
https://github.com/llvm/llvm-project/pull/92200
More information about the cfe-commits
mailing list