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

Jeremy Rifkin via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 16 17:20:50 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) {
----------------
jeremy-rifkin wrote:

Thanks for taking a look. What I was trying to do here was make a control flow graph where the out of bounds access happened in a path clang knew was unreachable (and thus not fire). I'm not sure if that's tested anywhere else. Checking if the warning is emitted here with the switch seems a little redundant to me with other checks about no longer assuming the default path is unreachable if enum values are covered. Thoughts?

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


More information about the cfe-commits mailing list