OSDN Git Service

2009-02-02 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / warn / pr36921.C
1 /* PR 36921: comparison operator can be overloaded. Do not emit
2    warnings in such case.
3  { dg-do compile }
4  { dg-options "-Wparentheses" }
5 */
6 struct A {};
7 A operator<(A, A) { return A(); }
8 A operator>(A, A) { return A(); }
9 A operator<=(A, A) { return A(); }
10 A operator>=(A, A) { return A(); }
11 A operator==(A, A) { return A(); }
12 A operator!=(A, A) { return A(); }
13
14 int main() {
15   A() < A() < A(); // should not emit warning
16   1 < 2 < 3; // { dg-warning "mathematical meaning" "parentheses" }
17   A() > A() > A(); // should not emit warning
18   1 > 2 > 3; // { dg-warning "mathematical meaning" "parentheses" }
19   A() <= A() <= A(); // should not emit warning
20   1 <= 2 <= 3; // { dg-warning "mathematical meaning" "parentheses" }
21   A() >= A() >= A(); // should not emit warning
22   1 >= 2 >= 3; // { dg-warning "mathematical meaning" "parentheses" }
23
24   A() == A() < A (); // { dg-warning "suggest parentheses" "parentheses" }
25   A() < A() != A (); // { dg-warning "suggest parentheses" "parentheses" }
26   return 0;
27 }