[clang] [clang][Sema] Add -Wswitch-default warning option (PR #73077)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 18 20:13:36 PST 2023
================
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-default %s
+
+int f1(int a) {
+ switch (a) { // expected-warning {{'switch' missing 'default' label}}
+ case 1: a++; break;
+ case 2: a += 2; break;
+ }
+ return a;
+}
----------------
shafik wrote:
Might be worth adding a test case that shows that this warns even for completely covered switches e.g. https://godbolt.org/z/zbqr6P5xc
https://github.com/llvm/llvm-project/pull/73077
More information about the cfe-commits
mailing list