================
@@ -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'd like an additional test along the lines of:
```
(void)((x < y) >= z);
```
and what about something along these lines?
```
struct S {
bool operator<(const S &) const;
} s, t;
(void)(s < t >= z);
```
perhaps that should diagnose while this should not?
```
struct S {
S operator<(const S &) const;
} a, b;
struct T {
friend bool operator>=(const S &, const T &);
} c;
bool val = (a < b >= c);
```
https://github.com/llvm/llvm-project/pull/92200
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits