]> granicus.if.org Git - clang/commitdiff
Put the tautological-comparison-of-unsigned-against-zero warnings in
authorJohn McCall <rjmccall@apple.com>
Wed, 8 Sep 2010 02:01:27 +0000 (02:01 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 8 Sep 2010 02:01:27 +0000 (02:01 +0000)
-Wtautological-compare instead of -Wsign-compare, which also implies turning
them on by default.

Restoration of r112877.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113334 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
test/Analysis/additive-folding.c
test/Analysis/null-deref-ps.c

index d4b7f1f55743fc17b516fb890dd2cce29c00c736..dade38e4e346081bbb3ac0ac17cef030eb39fcf2 100644 (file)
@@ -101,6 +101,7 @@ def SignCompare : DiagGroup<"sign-compare">;
 def : DiagGroup<"stack-protector">;
 def : DiagGroup<"switch-default">;
 def : DiagGroup<"synth">;
+def TautologicalCompare : DiagGroup<"tautological-compare">;
 
 // Preprocessor warnings.
 def : DiagGroup<"builtin-macro-redefined">;
index e3c9967f9e4a22ab18cf9f9886790e404838e1f8..7ec98a69f39c827a0cd915e84f680aba8e9ad3ac 100644 (file)
@@ -2204,10 +2204,10 @@ def warn_mixed_sign_conditional : Warning<
   InGroup<SignCompare>, DefaultIgnore;
 def warn_lunsigned_always_true_comparison : Warning<
   "comparison of unsigned expression %0 is always %1">,
-  InGroup<SignCompare>, DefaultIgnore;
+  InGroup<TautologicalCompare>;
 def warn_runsigned_always_true_comparison : Warning<
   "comparison of %0 unsigned expression is always %1">,
-  InGroup<SignCompare>, DefaultIgnore;
+  InGroup<TautologicalCompare>;
 
 def err_invalid_this_use : Error<
   "invalid use of 'this' outside of a nonstatic member function">;
@@ -3068,7 +3068,7 @@ def err_ret_local_block : Error<
 // Array comparisons have similar warnings
 def warn_comparison_always : Warning<
   "%select{self-|array }0comparison always evaluates to %select{false|true|a constant}1">,
-  InGroup<DiagGroup<"tautological-compare">>;
+  InGroup<TautologicalCompare>;
 
 def warn_stringcompare : Warning<
   "result of comparison against %select{a string literal|@encode}0 is "
index e4a565133968f4f0247c3dbfc21100bf1548eddf..713f788ac0d2352f198946e601d43deff883c055 100644 (file)
@@ -183,14 +183,14 @@ void tautologyGT (unsigned a) {
 
 void tautologyGE (unsigned a) {
   char* b = malloc(1);
-  if (a >= 0)
+  if (a >= 0) // expected-warning{{always true}}
     free(b);
   return; // no-warning
 }
 
 void tautologyLT (unsigned a) {
   char* b = malloc(1);
-  if (a < 0)
+  if (a < 0) // expected-warning{{always false}}
     return; // expected-warning{{never executed}}
   free(b);
 }
index 8daa84506818998907f67a8ce4feb5846d5850ad..d4d18b4ff3b22e54d911080e920570c1b74f5c20 100644 (file)
@@ -237,7 +237,7 @@ int* f10(int* p, signed char x, int y) {
 // Test case from <rdar://problem/6407949>
 void f11(unsigned i) {
   int *x = 0;
-  if (i >= 0) {
+  if (i >= 0) { // expected-warning{{always true}}
     // always true
   } else {
     *x = 42; // no-warning