diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2017-10-15 20:13:17 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2017-10-15 20:13:17 +0000 |
commit | 6de129e710cfb2857064b236e90d53c0c41ea92c (patch) | |
tree | f39f8a781241ff458ddf3ac592e95dcbfd0e36bc /clang/test/Sema/outof-range-constant-compare.c | |
parent | ac9309a112197f34319c5063ba3675614de1e04f (diff) | |
download | bcm5719-llvm-6de129e710cfb2857064b236e90d53c0c41ea92c.tar.gz bcm5719-llvm-6de129e710cfb2857064b236e90d53c0c41ea92c.zip |
[Sema] Re-land: Diagnose tautological comparison with type's min/max values
The first attempt, rL315614 was reverted because one libcxx
test broke, and i did not know at the time how to deal with it.
Summary:
Currently, clang only diagnoses completely out-of-range comparisons (e.g. `char` and constant `300`),
and comparisons of unsigned and `0`. But gcc also does diagnose the comparisons with the
`std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to speak
Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
Continuation of https://reviews.llvm.org/D37565
Reviewers: rjmccall, rsmith, aaron.ballman
Reviewed By: rsmith
Subscribers: rtrieu, jroelofs, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D38101
llvm-svn: 315875
Diffstat (limited to 'clang/test/Sema/outof-range-constant-compare.c')
-rw-r--r-- | clang/test/Sema/outof-range-constant-compare.c | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/clang/test/Sema/outof-range-constant-compare.c b/clang/test/Sema/outof-range-constant-compare.c index 36b6ff69ca7..ccb55e4a166 100644 --- a/clang/test/Sema/outof-range-constant-compare.c +++ b/clang/test/Sema/outof-range-constant-compare.c @@ -7,58 +7,6 @@ int main() { int a = value(); - if (a == 0x0000000000000000L) - return 0; - if (a != 0x0000000000000000L) - return 0; - if (a < 0x0000000000000000L) - return 0; - if (a <= 0x0000000000000000L) - return 0; - if (a > 0x0000000000000000L) - return 0; - if (a >= 0x0000000000000000L) - return 0; - - if (0x0000000000000000L == a) - return 0; - if (0x0000000000000000L != a) - return 0; - if (0x0000000000000000L < a) - return 0; - if (0x0000000000000000L <= a) - return 0; - if (0x0000000000000000L > a) - return 0; - if (0x0000000000000000L >= a) - return 0; - - if (a == 0x0000000000000000UL) - return 0; - if (a != 0x0000000000000000UL) - return 0; - if (a < 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression < 0 is always false}} - return 0; - if (a <= 0x0000000000000000UL) - return 0; - if (a > 0x0000000000000000UL) - return 0; - if (a >= 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}} - return 0; - - if (0x0000000000000000UL == a) - return 0; - if (0x0000000000000000UL != a) - return 0; - if (0x0000000000000000UL < a) - return 0; - if (0x0000000000000000UL <= a) // expected-warning {{comparison of 0 <= unsigned expression is always true}} - return 0; - if (0x0000000000000000UL > a) // expected-warning {{comparison of 0 > unsigned expression is always false}} - return 0; - if (0x0000000000000000UL >= a) - return 0; - if (a == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}} return 0; if (a != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}} @@ -155,113 +103,6 @@ int main() if (0x1234567812345678L >= l) return 0; - unsigned un = 0; - if (un == 0x0000000000000000L) - return 0; - if (un != 0x0000000000000000L) - return 0; - if (un < 0x0000000000000000L) // expected-warning {{comparison of unsigned expression < 0 is always false}} - return 0; - if (un <= 0x0000000000000000L) - return 0; - if (un > 0x0000000000000000L) - return 0; - if (un >= 0x0000000000000000L) // expected-warning {{comparison of unsigned expression >= 0 is always true}} - return 0; - - if (0x0000000000000000L == un) - return 0; - if (0x0000000000000000L != un) - return 0; - if (0x0000000000000000L < un) - return 0; - if (0x0000000000000000L <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}} - return 0; - if (0x0000000000000000L > un) // expected-warning {{comparison of 0 > unsigned expression is always false}} - return 0; - if (0x0000000000000000L >= un) - return 0; - - if (un == 0x0000000000000000UL) - return 0; - if (un != 0x0000000000000000UL) - return 0; - if (un < 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression < 0 is always false}} - return 0; - if (un <= 0x0000000000000000UL) - return 0; - if (un > 0x0000000000000000UL) - return 0; - if (un >= 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}} - return 0; - - if (0x0000000000000000UL == un) - return 0; - if (0x0000000000000000UL != un) - return 0; - if (0x0000000000000000UL < un) - return 0; - if (0x0000000000000000UL <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}} - return 0; - if (0x0000000000000000UL > un) // expected-warning {{comparison of 0 > unsigned expression is always false}} - return 0; - if (0x0000000000000000UL >= un) - return 0; - - float fl = 0; - if (fl == 0x0000000000000000L) - return 0; - if (fl != 0x0000000000000000L) - return 0; - if (fl < 0x0000000000000000L) - return 0; - if (fl <= 0x0000000000000000L) - return 0; - if (fl > 0x0000000000000000L) - return 0; - if (fl >= 0x0000000000000000L) - return 0; - - if (0x0000000000000000L == fl) - return 0; - if (0x0000000000000000L != fl) - return 0; - if (0x0000000000000000L < fl) - return 0; - if (0x0000000000000000L <= fl) - return 0; - if (0x0000000000000000L > fl) - return 0; - if (0x0000000000000000L >= fl) - return 0; - - double dl = 0; - if (dl == 0x0000000000000000L) - return 0; - if (dl != 0x0000000000000000L) - return 0; - if (dl < 0x0000000000000000L) - return 0; - if (dl <= 0x0000000000000000L) - return 0; - if (dl > 0x0000000000000000L) - return 0; - if (dl >= 0x0000000000000000L) - return 0; - - if (0x0000000000000000L == dl) - return 0; - if (0x0000000000000000L != dl) - return 0; - if (0x0000000000000000L < dl) - return 0; - if (0x0000000000000000L <= dl) - return 0; - if (0x0000000000000000L > dl) - return 0; - if (0x0000000000000000L >= dl) - return 0; - enum E { yes, no, |