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

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Tue May 6 01:50:24 PDT 2025


zmodem wrote:

I wonder if we should also do something special about the `-Wdeprecated-declarations` diagnostic in switches.

If the user fixes the -Wswitch  / -Wreturn-type warnings from `testSwitchFour` the natural way:

```
int testSwitchFour(enum SwitchFour e) {
  switch (e) {
  case Red:   return 1;
  case Green: return 2;
  case Blue:  return 3;
  }
} 
```

They will get `warning: 'Blue' is deprecated [-Wdeprecated-declarations]` instead.

Maybe we should suppress that warning for switch cases? Or suggest adding a `default` label instead?

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


More information about the cfe-commits mailing list