[llvm-branch-commits] [cfe-tag] r96552 - in /cfe/tags/Apple/clang/clang/tools/clang: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaStmt.cpp test/Sema/switch.c

Douglas Gregor dgregor at apple.com
Wed Feb 17 17:48:24 PST 2010


Author: dgregor
Date: Wed Feb 17 19:48:23 2010
New Revision: 96552

URL: http://llvm.org/viewvc/llvm-project?rev=96552&view=rev
Log:
Merge fix for radar 7658121

Modified:
    cfe/tags/Apple/clang/clang/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/SemaStmt.cpp
    cfe/tags/Apple/clang/clang/tools/clang/test/Sema/switch.c

Modified: cfe/tags/Apple/clang/clang/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/tags/Apple/clang/clang/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td?rev=96552&r1=96551&r2=96552&view=diff

==============================================================================
--- cfe/tags/Apple/clang/clang/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/tags/Apple/clang/clang/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td Wed Feb 17 19:48:23 2010
@@ -2577,7 +2577,8 @@
 def warn_bool_switch_condition : Warning<
   "switch condition is a bool">;
 def warn_case_value_overflow : Warning<
-  "overflow converting case value to switch condition type (%0 to %1)">;
+  "overflow converting case value to switch condition type (%0 to %1)">,
+  InGroup<DiagGroup<"switch">>;
 def err_duplicate_case : Error<"duplicate case value '%0'">;
 def warn_case_empty_range : Warning<"empty case range specified">;
 def warn_missing_cases : Warning<"enumeration value %0 not handled in switch">,

Modified: cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/SemaStmt.cpp?rev=96552&r1=96551&r2=96552&view=diff

==============================================================================
--- cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/SemaStmt.cpp (original)
+++ cfe/tags/Apple/clang/clang/tools/clang/lib/Sema/SemaStmt.cpp Wed Feb 17 19:48:23 2010
@@ -340,11 +340,11 @@
   } else if (NewSign != Val.isSigned()) {
     // Convert the sign to match the sign of the condition.  This can cause
     // overflow as well: unsigned(INTMIN)
+    // We don't diagnose this overflow, because it is implementation-defined 
+    // behavior.
+    // FIXME: Introduce a second, default-ignored warning for this case?
     llvm::APSInt OldVal(Val);
     Val.setIsSigned(NewSign);
-
-    if (Val.isNegative())  // Sign bit changes meaning.
-      Diag(Loc, DiagID) << OldVal.toString(10) << Val.toString(10);
   }
 }
 

Modified: cfe/tags/Apple/clang/clang/tools/clang/test/Sema/switch.c
URL: http://llvm.org/viewvc/llvm-project/cfe/tags/Apple/clang/clang/tools/clang/test/Sema/switch.c?rev=96552&r1=96551&r2=96552&view=diff

==============================================================================
--- cfe/tags/Apple/clang/clang/tools/clang/test/Sema/switch.c (original)
+++ cfe/tags/Apple/clang/clang/tools/clang/test/Sema/switch.c Wed Feb 17 19:48:23 2010
@@ -223,3 +223,17 @@
       break;
   }
 }
+
+// <rdar://problem/7658121>
+enum {
+  EC0 = 0xFFFF0000,
+  EC1 = 0xFFFF0001,
+};
+
+int test14(int a) {
+  switch(a) {
+  case EC0: return 0;
+  case EC1: return 1;
+  }
+  return 0;
+}





More information about the llvm-branch-commits mailing list