[PATCH] D51545: Enable -Wtautological-unsigned-zero-compare under -Wextra
Elizabeth Andrews via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 31 08:51:38 PDT 2018
eandrews created this revision.
eandrews added reviewers: lebedev.ri, rsmith, rjmccall, rnk, mclow.lists, erichkeane.
GCC enables -Wtype-limits under -Wextra. Warnings under GCC's -Wtype-limits is covered in Clang by -Wtautological-type-limit-compare and -Wtautological-unsigned-zero-compare.
Since -Wtautological-type-limit-compare can fire spuriously when a type's size is platform-dependent (as detailed in D41512 <https://reviews.llvm.org/D41512>), I am adding only -Wtautological-unsigned-zero-compare to -Wextra.
I should point out that GCC does not throw warnings on pointless unsigned expression comparisons inside templates while -Wtautological-unsigned-zero-compare does. I figure this is a limitation in GCC's implementation and don't think this is an issue but please feel free to let me know if I am mistaken.
https://reviews.llvm.org/D51545
Files:
include/clang/Basic/DiagnosticGroups.td
test/Sema/tautological-unsigned-zero-compare.c
Index: test/Sema/tautological-unsigned-zero-compare.c
===================================================================
--- test/Sema/tautological-unsigned-zero-compare.c
+++ test/Sema/tautological-unsigned-zero-compare.c
@@ -8,6 +8,12 @@
// RUN: -verify -x c++ %s
// RUN: %clang_cc1 -fsyntax-only \
// RUN: -verify=silence -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only \
+// RUN: -Wextra -Wno-sign-compare\
+// RUN: -verify %s
+// RUN: %clang_cc1 -fsyntax-only \
+// RUN: -Wextra -Wno-sign-compare\
+// RUN: -verify -x c++ %s
unsigned uvalue(void);
signed int svalue(void);
Index: include/clang/Basic/DiagnosticGroups.td
===================================================================
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -763,7 +763,8 @@
MissingMethodReturnType,
SignCompare,
UnusedParameter,
- NullPointerArithmetic
+ NullPointerArithmetic,
+ TautologicalUnsignedZeroCompare
]>;
def Most : DiagGroup<"most", [
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51545.163536.patch
Type: text/x-patch
Size: 1074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180831/18e37cf4/attachment-0001.bin>
More information about the cfe-commits
mailing list