[clang] e5eef6e - [Clang][Wswitch-default] Warning for enum even completely covered the cases (#75900)

via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 19 18:26:31 PST 2023


Author: hstk30-hw
Date: 2023-12-20T10:26:27+08:00
New Revision: e5eef6e24f06dfffc77cffc6963e8543f9d223bd

URL: https://github.com/llvm/llvm-project/commit/e5eef6e24f06dfffc77cffc6963e8543f9d223bd
DIFF: https://github.com/llvm/llvm-project/commit/e5eef6e24f06dfffc77cffc6963e8543f9d223bd.diff

LOG: [Clang][Wswitch-default] Warning for enum even completely covered the cases (#75900)

 Adding a test case that this warns even for completely covered switches.

Added: 
    

Modified: 
    clang/test/Sema/switch-default.c

Removed: 
    


################################################################################
diff  --git a/clang/test/Sema/switch-default.c b/clang/test/Sema/switch-default.c
index 854b561b37c48e..342a97ee68b1e2 100644
--- a/clang/test/Sema/switch-default.c
+++ b/clang/test/Sema/switch-default.c
@@ -15,3 +15,14 @@ int f2(int a) {
   }
   return a;
 }
+
+// Warn even completely covered Enum cases(GCC compatibility).
+enum E { A, B };
+enum E check_enum(enum E e) {
+  switch (e) {                // expected-warning {{'switch' missing 'default' label}}
+    case A: break;
+    case B: break;
+  }
+  return e;
+}
+


        


More information about the cfe-commits mailing list