[clang] [Clang][Analysis] Don't treat the default switch path as unreachable when all enumerators are covered (PR #123166)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 16 17:24:53 PST 2025


================
@@ -170,16 +170,14 @@ void test_nested_switch() {
   }
 }
 
-// Test that if all the values of an enum covered, that the 'default' branch
-// is unreachable.
+// Test that a warning is not emitted if the code is unreachable.
 enum Values { A, B, C, D };
 void test_all_enums_covered(enum Values v) {
----------------
Sirraide wrote:

I mean, I’d imagine we have tests for that elsewhere, if not, then
```c++
void f() {
    int x[2];
    goto foo;
    x[2] = 7;
    foo:;
}
```
works. If that’s all we care about here, then we can just replace it with this, otherwise, we can probably just remove it entirely. I haven’t looked at the rest of this file too much.

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


More information about the cfe-commits mailing list