[cfe-commits] r148781 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td test/Sema/switch-enum.c test/Sema/switch.c

David Blaikie dblaikie at gmail.com
Mon Jan 23 20:56:26 PST 2012


Author: dblaikie
Date: Mon Jan 23 22:56:25 2012
New Revision: 148781

URL: http://llvm.org/viewvc/llvm-project?rev=148781&view=rev
Log:
Improve -Wswitch-enum diagnostic message.

Changing wording to include the word "explicitly" (as in "enumeration value ...
not /explicitly/ handled by switch"), as suggested by Richard Smith.

Also, now that the diagnostic text differs between -Wswitch and -Wswitch-enum,
I've simplified the test cases a bit.

Removed:
    cfe/trunk/test/Sema/switch-enum.c
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/test/Sema/switch.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=148781&r1=148780&r2=148781&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan 23 22:56:25 2012
@@ -4962,16 +4962,16 @@
   Warning<"no case matching constant switch condition '%0'">;
 
 def warn_def_missing_case1 : Warning<
-  "enumeration value %0 not handled in switch">,
+  "enumeration value %0 not explicitly handled in switch">,
   InGroup<SwitchEnum>, DefaultIgnore;
 def warn_def_missing_case2 : Warning<
-  "enumeration values %0 and %1 not handled in switch">,
+  "enumeration values %0 and %1 not explicitly handled in switch">,
   InGroup<SwitchEnum>, DefaultIgnore;
 def warn_def_missing_case3 : Warning<
-  "enumeration values %0, %1, and %2 not handled in switch">,
+  "enumeration values %0, %1, and %2 not explicitly handled in switch">,
   InGroup<SwitchEnum>, DefaultIgnore;
 def warn_def_missing_cases : Warning<
-  "%0 enumeration values not handled in switch: %1, %2, %3...">,
+  "%0 enumeration values not explicitly handled in switch: %1, %2, %3...">,
   InGroup<SwitchEnum>, DefaultIgnore;
 
 def warn_missing_case1 : Warning<"enumeration value %0 not handled in switch">,

Removed: cfe/trunk/test/Sema/switch-enum.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/switch-enum.c?rev=148780&view=auto
==============================================================================
--- cfe/trunk/test/Sema/switch-enum.c (original)
+++ cfe/trunk/test/Sema/switch-enum.c (removed)
@@ -1,18 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum -Wno-switch-redundant-default %s
-
-int test1() {
-  enum { A, B } a;
-  switch (a) { //expected-warning{{enumeration value 'B' not handled in switch}}
-  case A: return 1;
-  default: return 2;
-  }
-}
-
-int test2() {
-  enum { A, B } a;
-  switch (a) {
-  case A: return 1;
-  case B: return 2;
-  default: return 3;
-  }
-}

Modified: cfe/trunk/test/Sema/switch.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/switch.c?rev=148781&r1=148780&r2=148781&view=diff
==============================================================================
--- cfe/trunk/test/Sema/switch.c (original)
+++ cfe/trunk/test/Sema/switch.c Mon Jan 23 22:56:25 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum %s
 void f (int z) { 
   while (z) { 
     default: z--;            // expected-error {{statement not in switch}}
@@ -203,7 +203,7 @@
       break;
   }
 
-  switch(a) {
+  switch(a) { //expected-warning{{enumeration value 'A' not explicitly handled in switch}}
     case B:
     case C:
       break;
@@ -294,14 +294,7 @@
   switch (a) {
   case A: return 0;
   case B: return 1;
-  default: return 2; // expected-warning {{default is unreachable as all enumeration values are accounted for}}
-  }
-}
-
-int test19() {
-  enum { A, B } a;
-  switch (a) {
   case 7: return 1; // expected-warning {{case value not in enumerated type}}
-  default: return 3;
+  default: return 2; // expected-warning {{default is unreachable as all enumeration values are accounted for}}
   }
 }





More information about the cfe-commits mailing list