[clang] 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 15:57:44 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 think what this tests is checking is that we don’t emit a warning for the invalid array access because it is supposed to be unreachable. With this pr, this is no longer treated as unreachable, so the right change here imo would be to check that the warning *is* emitted.

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


More information about the cfe-commits mailing list