[clang] [Sema] Warn about omitting deprecated enumerator in switch (PR #138562)

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Mon May 5 12:53:52 PDT 2025


================
@@ -15,7 +15,7 @@ enum SwitchTwo {
 };
 
 void testSwitchTwo(enum SwitchTwo st) {
-  switch (st) {} // expected-warning{{enumeration values 'Vim' and 'Emacs' not handled in switch}}
+  switch (st) {} // expected-warning{{enumeration values 'Ed', 'Vim' and 'Emacs' not handled in switch}}
 }
 
----------------
rnk wrote:

We should have some test showing that the statement after the switch is considered reachable. You can build one with -Wreturn-type and an int return:
```
int doswitch(SwitchTwo e) {
  switch (e) {
  case Emacs: return 42;
  }
} // expected-warning {{asdf}}
```

https://github.com/llvm/llvm-project/pull/138562


More information about the cfe-commits mailing list