atomic-compare.c 900 B

1234567891011121314151617181920212223242526
  1. // RUN: %clang_cc1 %s -verify -fsyntax-only
  2. void f(_Atomic(int) a, _Atomic(int) b) {
  3. if (a > b) {} // no warning
  4. if (a < b) {} // no warning
  5. if (a >= b) {} // no warning
  6. if (a <= b) {} // no warning
  7. if (a == b) {} // no warning
  8. if (a != b) {} // no warning
  9. if (a == 0) {} // no warning
  10. if (a > 0) {} // no warning
  11. if (a > 1) {} // no warning
  12. if (a > 2) {} // no warning
  13. if (!a > 0) {} // no warning
  14. if (!a > 1) {} // expected-warning {{comparison of constant 1 with boolean expression is always false}}
  15. if (!a > 2) {} // expected-warning {{comparison of constant 2 with boolean expression is always false}}
  16. if (!a > b) {} // no warning
  17. if (!a > -1) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}}
  18. }
  19. typedef _Atomic(int) Ty;
  20. void PR23638(Ty *a) {
  21. if (*a == 1) {} // no warning
  22. }