[PATCH] D134207: [Clang] Support case and default labels at end of compound statement

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 20 13:07:23 PDT 2022


aaron.ballman added inline comments.


================
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
----------------
Izaron wrote:
> 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?
I think a helper function to diagnose this would not be a bad thing.


================
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:
----------------
Izaron wrote:
> I feel like we may be having redundant tests, because `Parser/c2x-label.c` and `C2x/n2508.c` test the same things...
Yup, we'll definitely have redundancy in the tests -- the tests under the `C` directory are for (eventually) automatically filling out: https://clang.llvm.org/c_status.html instead of relying on folks to manually modify the HTML every time. So they're mostly "do the examples from the paper work" kind of tests, whereas the Parser/Sema/etc tests are going to test a LOT more edge cases.


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