================ @@ -132,3 +132,30 @@ bool f(); template <typename... T> void g(bool = (f<T>() || ...)); } + + +namespace comparison_warning { + struct S { + bool operator<(const S&) const; + bool operator<(int) const; + bool operator==(const S&) const; + }; + + template <typename...T> + void f(T... ts) { + (void)(ts == ...); + // expected-error@-1 2{{comparison in fold expression would evaluate to '(X == Y) == Z'}} + (void)(ts < ...); + // expected-error@-1 2{{comparison in fold expression would evaluate to '(X < Y) < Z'}} + (void)(... < ts); + // expected-error@-1 2{{comparison in fold expression would evaluate to '(X < Y) < Z'}} + } + + void test() { + f(0, 1, 2); // expected-note{{in instantiation}} + f(0, 1); // expected-note{{in instantiation}} ---------------- cor3ntin wrote:
This is intended -, ideally, we would even warn when `n <= 1` (ie, the size of the pack should not affect the warning) - but that would be annoying because there could be user-defined operators, and we only discover that for n >=2. https://github.com/llvm/llvm-project/pull/136836 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits