[PATCH] D134207: [Clang] Support case and default labels at end of compound statement
Evgeny Shulgin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 19 12:30:03 PDT 2022
Izaron added inline comments.
================
Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:298-299
"and have an empty entry in the selector">;
-def err_switch_label_end_of_compound_statement : Error<
- "label at end of switch compound statement: expected statement">;
def ext_c_label_end_of_compound_statement : ExtWarn<
----------------
This is not an error anymore
================
Comment at: clang/lib/Parse/ParseStmt.cpp:948-956
+ if (getLangOpts().CPlusPlus) {
+ Diag(Tok, getLangOpts().CPlusPlus2b
+ ? diag::warn_cxx20_compat_label_end_of_compound_statement
+ : diag::ext_cxx_label_end_of_compound_statement);
+ } else {
+ Diag(Tok, getLangOpts().C2x
+ ? diag::warn_c2x_compat_label_end_of_compound_statement
----------------
We have copy-pasted this piece of code in 3 places (simple label, case label, default label). Does it make sense to have a method for label diags?
================
Comment at: clang/test/Parser/c2x-label.c:12-30
+int test_label_in_switch(int v) {
+ switch (v) {
+ case 1:
+ return 1;
+ case 2:
+ return 2;
+ case 3: case 4: case 5:
----------------
I feel like we may be having redundant tests, because `Parser/c2x-label.c` and `C2x/n2508.c` test the same things...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134207/new/
https://reviews.llvm.org/D134207
More information about the cfe-commits
mailing list