Skip to content

[Clang][Wswitch-default] Warning for enum even completely covered the cases #75900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2023

Conversation

hstk30-hw
Copy link
Contributor

No description provided.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Dec 19, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 19, 2023

@llvm/pr-subscribers-clang

Author: None (hstk30-hw)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/75900.diff

1 Files Affected:

  • (modified) clang/test/Sema/switch-default.c (+11)
diff --git a/clang/test/Sema/switch-default.c b/clang/test/Sema/switch-default.c
index 854b561b37c48e..342a97ee68b1e2 100644
--- a/clang/test/Sema/switch-default.c
+++ b/clang/test/Sema/switch-default.c
@@ -15,3 +15,14 @@ int f2(int a) {
   }
   return a;
 }
+
+// Warn even completely covered Enum cases(GCC compatibility).
+enum E { A, B };
+enum E check_enum(enum E e) {
+  switch (e) {                // expected-warning {{'switch' missing 'default' label}}
+    case A: break;
+    case B: break;
+  }
+  return e;
+}
+

Copy link
Contributor

@dongjianqiang2 dongjianqiang2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dongjianqiang2 dongjianqiang2 merged commit e5eef6e into llvm:main Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants