diff options
| author | Hans Wennborg <hans@hanshq.net> | 2017-12-08 16:54:08 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2017-12-08 16:54:08 +0000 |
| commit | 5791ce77baa8eeba268bffb40a2757bea1de8741 (patch) | |
| tree | a972435d546cace39619740f74d647ba69591818 /clang/test/SemaCXX/compare.cpp | |
| parent | 19d460b066d755f188c03b28a4063d3d0c32a89a (diff) | |
| download | bcm5719-llvm-5791ce77baa8eeba268bffb40a2757bea1de8741.tar.gz bcm5719-llvm-5791ce77baa8eeba268bffb40a2757bea1de8741.zip | |
Revert "Unify implementation of our two different flavours of -Wtautological-compare."
> Unify implementation of our two different flavours of -Wtautological-compare.
>
> In so doing, fix a handful of remaining bugs where we would report false
> positives or false negatives if we promote a signed value to an unsigned type
> for the comparison.
This caused a new warning in Chromium:
../../base/trace_event/trace_log.cc:1545:29: error: comparison of constant 64
with expression of type 'unsigned int' is always true
[-Werror,-Wtautological-constant-out-of-range-compare]
DCHECK(handle.event_index < TraceBufferChunk::kTraceBufferChunkSize);
~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'unsigned int' is really a 6-bit bitfield, which is why it's always
less than 64.
I thought we didn't use to warn (with out-of-range-compare) when comparing
against the boundaries of a type?
llvm-svn: 320162
Diffstat (limited to 'clang/test/SemaCXX/compare.cpp')
| -rw-r--r-- | clang/test/SemaCXX/compare.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/test/SemaCXX/compare.cpp b/clang/test/SemaCXX/compare.cpp index 388578b5807..1d940be629a 100644 --- a/clang/test/SemaCXX/compare.cpp +++ b/clang/test/SemaCXX/compare.cpp @@ -245,8 +245,8 @@ void test4(short s) { // unsigned. const unsigned B = -1; void (s < B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} - void (s > B); // expected-warning{{comparison 'short' > 4294967295 is always false}} - void (s <= B); // expected-warning{{comparison 'short' <= 4294967295 is always true}} + void (s > B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} + void (s <= B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} void (s >= B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} void (s == B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} void (s != B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}} |

