From: John McCall Date: Wed, 8 Sep 2010 02:01:27 +0000 (+0000) Subject: Put the tautological-comparison-of-unsigned-against-zero warnings in X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8205c1a5c623a418f06789f222183ed5040ff4c9;p=clang Put the tautological-comparison-of-unsigned-against-zero warnings in -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 --- diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index d4b7f1f557..dade38e4e3 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -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">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index e3c9967f9e..7ec98a69f3 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2204,10 +2204,10 @@ def warn_mixed_sign_conditional : Warning< InGroup, DefaultIgnore; def warn_lunsigned_always_true_comparison : Warning< "comparison of unsigned expression %0 is always %1">, - InGroup, DefaultIgnore; + InGroup; def warn_runsigned_always_true_comparison : Warning< "comparison of %0 unsigned expression is always %1">, - InGroup, DefaultIgnore; + InGroup; 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>; + InGroup; def warn_stringcompare : Warning< "result of comparison against %select{a string literal|@encode}0 is " diff --git a/test/Analysis/additive-folding.c b/test/Analysis/additive-folding.c index e4a5651339..713f788ac0 100644 --- a/test/Analysis/additive-folding.c +++ b/test/Analysis/additive-folding.c @@ -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); } diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index 8daa845068..d4d18b4ff3 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -237,7 +237,7 @@ int* f10(int* p, signed char x, int y) { // Test case from void f11(unsigned i) { int *x = 0; - if (i >= 0) { + if (i >= 0) { // expected-warning{{always true}} // always true } else { *x = 42; // no-warning