emaxx-google wrote: > > then add another enumerator `C`, now `-Wswitch` won’t fire because there is > > a `default` case > > To elaborate, the behaviour that I at least would like to have is > > 1. When I add an enumerator, I want the compiler to warn on every `switch` > statement that switches on that enum so I know that I have to update it. > 2. At the same time, there should be some way to opt out of this because I > don’t want to have to add like 20 instances of `case Foo: > std::unreachable();`. > 3. Lastly, I want the compiler to assume that we can fall off the end of the > switch statement so that I’m forced to put a `std::unreachable()` or > something like it there to make sure we don’t fall off the end of the > function. > > The status quo is that w/ `-Wswitch` (which is enabled by default), `default` > labels do 1 and 2, but you want 3. But with the approach in this pr, you get > 2 and 3, but not 1 (and w/ `-Wswitch-enum` you get 1 only at the moment and 1 > and 3 with this pr). Ideally, I’d like to find some approach that provides 1, > 2, _and_ 3.
Good point, and we came to the same conclusion after checking this with other Chromium V8 maintainers (the project where this diagnostic is very desired from the security standpoint). https://github.com/llvm/llvm-project/pull/198416 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
