]> granicus.if.org Git - clang/commit
[Sema] -Wtautological-compare: handle comparison of unsigned with 0S.
authorRoman Lebedev <lebedev.ri@gmail.com>
Thu, 7 Sep 2017 22:14:25 +0000 (22:14 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Thu, 7 Sep 2017 22:14:25 +0000 (22:14 +0000)
commitd579a6ffbf151fea5dde073aed43654f98e61abc
treea1793a25df35ffc002be52b2a87764e18f1caf77
parentfe69623a6b187836ceaff43486550ed4df04a17f
[Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

Summary:
This is a first half(?) of a fix for the following bug:
https://bugs.llvm.org/show_bug.cgi?id=34147 (gcc -Wtype-limits)

GCC's -Wtype-limits does warn on comparison of unsigned value
with signed zero (as in, with 0), but clang only warns if the
zero is unsigned (i.e. 0U).

Also, be careful not to double-warn, or falsely warn on
comparison of signed/fp variable and signed 0.

Yes, all these testcases are needed.

Testing: $ ninja check-clang-sema check-clang-semacxx
Also, no new warnings for clang stage-2 build.

Reviewers: rjmccall, rsmith, aaron.ballman

Reviewed By: rjmccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D37565

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312750 91177308-0d34-0410-b5e6-96231b3b80d8
docs/ReleaseNotes.rst
lib/Sema/SemaChecking.cpp
test/Sema/compare.c
test/Sema/outof-range-constant-compare.c
test/SemaCXX/compare.cpp