[PATCH] D37620: [Sema] Put tautological comparison of unsigned and zero into it's own flag
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 8 05:27:44 PDT 2017
lebedev.ri created this revision.
lebedev.ri added a project: clang.
As requested by Sam McCall.
$ /build/llvm-build-Clang-release/./bin/clang -c /build/clang/test/Sema/outof-range-constant-compare.c /build/clang/test/Sema/outof-range-constant-compare.c:40:11: warning: comparison of unsigned expression < 0 is always false [-Wtautological-unsigned-zero-compare]
if (a < 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}
~ ^ ~~~~~~~~~~~~~~~~~~~~
Does this need test?
Repository:
rL LLVM
https://reviews.llvm.org/D37620
Files:
include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5898,14 +5898,14 @@
InGroup<SignCompare>, DefaultIgnore;
def warn_lunsigned_always_true_comparison : Warning<
"comparison of unsigned%select{| enum}2 expression %0 is always %1">,
- InGroup<TautologicalCompare>;
+ InGroup<TautologicalUnsignedZeroCompare>;
def warn_out_of_range_compare : Warning<
"comparison of %select{constant %0|true|false}1 with "
"%select{expression of type %2|boolean expression}3 is always "
"%select{false|true}4">, InGroup<TautologicalOutOfRangeCompare>;
def warn_runsigned_always_true_comparison : Warning<
"comparison of %0 unsigned%select{| enum}2 expression is always %1">,
- InGroup<TautologicalCompare>;
+ InGroup<TautologicalUnsignedZeroCompare>;
def warn_comparison_of_mixed_enum_types : Warning<
"comparison of two values with different enumeration types"
"%diff{ ($ and $)|}0,1">,
Index: include/clang/Basic/DiagnosticGroups.td
===================================================================
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -427,12 +427,14 @@
def StringPlusInt : DiagGroup<"string-plus-int">;
def StringPlusChar : DiagGroup<"string-plus-char">;
def StrncatSize : DiagGroup<"strncat-size">;
+def TautologicalUnsignedZeroCompare : DiagGroup<"tautological-unsigned-zero-compare">;
def TautologicalOutOfRangeCompare : DiagGroup<"tautological-constant-out-of-range-compare">;
def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
def TautologicalCompare : DiagGroup<"tautological-compare",
- [TautologicalOutOfRangeCompare,
+ [TautologicalUnsignedZeroCompare,
+ TautologicalOutOfRangeCompare,
TautologicalPointerCompare,
TautologicalOverlapCompare,
TautologicalUndefinedCompare]>;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37620.114341.patch
Type: text/x-patch
Size: 2330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170908/922a383c/attachment.bin>
More information about the cfe-commits
mailing list