Currently, -Wsign-compare will warn if conditional operands differ in
signedness. This patch will move this warning to -Wmixed-sign-conditional
making -Wsign-compare only about signed comparisons.  Patch is attached and
available at http://codereview.appspot.com/4731042/
Index: test/Sema/conditional-expr.c
===================================================================
--- test/Sema/conditional-expr.c	(revision 135185)
+++ test/Sema/conditional-expr.c	(working copy)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wsign-compare %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wmixed-sign-conditional %s
 void foo() {
   *(0 ? (double *)0 : (void *)0) = 0;
   // FIXME: GCC doesn't consider the the following two statements to be errors.
Index: test/SemaCXX/warn-mixed-sign-conditional.cpp
===================================================================
--- test/SemaCXX/warn-mixed-sign-conditional.cpp	(revision 135185)
+++ test/SemaCXX/warn-mixed-sign-conditional.cpp	(working copy)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wsign-compare %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wmixed-sign-conditional %s
 
 // NOTE: When a 'enumeral mismatch' warning is implemented then expect several
 // of the following cases to be impacted.
Index: test/SemaCXX/conditional-expr.cpp
===================================================================
--- test/SemaCXX/conditional-expr.cpp	(revision 135185)
+++ test/SemaCXX/conditional-expr.cpp	(working copy)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++0x -Wsign-compare %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++0x -Wmixed-sign-conditional %s
 
 // C++ rules for ?: are a lot stricter than C rules, and have to take into
 // account more conversion options.
@@ -321,3 +321,5 @@
     (void)(true ? (void*)0 : A()); // expected-error{{incompatible operand types}}
   }
 }
+
+
Index: test/SemaCXX/warn-sign-compare.cpp
===================================================================
--- test/SemaCXX/warn-sign-compare.cpp	(revision 135185)
+++ test/SemaCXX/warn-sign-compare.cpp	(working copy)
@@ -1,72 +0,0 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wsign-compare %s
-
-// NOTE: When a 'enumeral mismatch' warning is implemented then expect several
-// of the following cases to be impacted.
-
-// namespace for anonymous enums tests
-namespace test1 {
-  enum { A };
-  enum { B = -1 };
-
-  template <typename T> struct Foo {
-    enum { C };
-    enum { D = ~0U };
-  };
-
-  enum { E = ~0U };
-
-  void doit_anonymous( int i ) {
-    int a1 = 1 ? i : A;
-    int a2 = 1 ? A : i;
-
-    int b1 = 1 ? i : B;
-    int b2 = 1 ? B : i;
-
-    int c1 = 1 ? i : Foo<bool>::C;
-    int c2 = 1 ? Foo<bool>::C : i;
-
-    int d1 = 1 ? i : Foo<bool>::D; // expected-warning {{operands of ? are integers of different signs}}
-    int d2 = 1 ? Foo<bool>::D : i; // expected-warning {{operands of ? are integers of different signs}}
-    int d3 = 1 ? B : Foo<bool>::D; // expected-warning {{operands of ? are integers of different signs}}
-    int d4 = 1 ? Foo<bool>::D : B; // expected-warning {{operands of ? are integers of different signs}}
-
-    int e1 = 1 ? i : E; // expected-warning {{operands of ? are integers of different signs}}
-    int e2 = 1 ? E : i; // expected-warning {{operands of ? are integers of different signs}}
-    int e3 = 1 ? E : B; // expected-warning {{operands of ? are integers of different signs}}
-    int e4 = 1 ? B : E; // expected-warning {{operands of ? are integers of different signs}}
-  }
-}
-
-// namespace for named enums tests
-namespace test2 {
-  enum Named1 { A };
-  enum Named2 { B = -1 };
-
-  template <typename T> struct Foo {
-    enum Named3 { C };
-    enum Named4 { D = ~0U };
-  };
-
-  enum Named5 { E = ~0U };
-
-  void doit_anonymous( int i ) {
-    int a1 = 1 ? i : A;
-    int a2 = 1 ? A : i;
-
-    int b1 = 1 ? i : B;
-    int b2 = 1 ? B : i;
-
-    int c1 = 1 ? i : Foo<bool>::C;
-    int c2 = 1 ? Foo<bool>::C : i;
-
-    int d1 = 1 ? i : Foo<bool>::D; // expected-warning {{operands of ? are integers of different signs}}
-    int d2 = 1 ? Foo<bool>::D : i; // expected-warning {{operands of ? are integers of different signs}}
-    int d3 = 1 ? B : Foo<bool>::D; // expected-warning {{operands of ? are integers of different signs}}
-    int d4 = 1 ? Foo<bool>::D : B; // expected-warning {{operands of ? are integers of different signs}}
-
-    int e1 = 1 ? i : E; // expected-warning {{operands of ? are integers of different signs}}
-    int e2 = 1 ? E : i; // expected-warning {{operands of ? are integers of different signs}}
-    int e3 = 1 ? E : B; // expected-warning {{operands of ? are integers of different signs}}
-    int e4 = 1 ? B : E; // expected-warning {{operands of ? are integers of different signs}}
-  }
-}
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td	(revision 135185)
+++ include/clang/Basic/DiagnosticSemaKinds.td	(working copy)
@@ -3041,7 +3041,7 @@
   InGroup<SignCompare>, DefaultIgnore;
 def warn_mixed_sign_conditional : Warning<
   "operands of ? are integers of different signs: %0 and %1">,
-  InGroup<SignCompare>, DefaultIgnore;
+  InGroup<DiagGroup<"mixed-sign-conditional">>, DefaultIgnore;
 def warn_lunsigned_always_true_comparison : Warning<
   "comparison of unsigned%select{| enum}2 expression %0 is always %1">,
   InGroup<TautologicalCompare>;
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp	(revision 135185)
+++ lib/Sema/SemaChecking.cpp	(working copy)
@@ -3241,7 +3241,7 @@
                                  CC))
     return;
 
-  // ...and -Wsign-compare isn't...
+  // ...and -Wmixed-sign-conditional isn't...
   if (!S.Diags.getDiagnosticLevel(diag::warn_mixed_sign_conditional, CC))
     return;
 
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to