[PATCH] D146393: [Clang] Support free positioning of labels inside compound statements in C

Evgeny Shulgin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 19 14:13:06 PDT 2023


Izaron added a comment.

A big TODO: rename `ext_c_label_end_of_compound_statement` to something like `ext_c_label_free_positioning`. Since we found out it is more complete than just the end of statements.



================
Comment at: clang/lib/Parse/ParseStmt.cpp:695-697
-  // The substatement is always a 'statement', not a 'declaration', but is
-  // otherwise in the same context as the labeled-statement.
-  StmtCtx &= ~ParsedStmtContext::AllowDeclarationsInC;
----------------
Place in code where it matters: https://github.com/llvm/llvm-project/blob/84870c4abbacfb97ca025c9219b724f381611380/clang/lib/Parse/ParseStmt.cpp#L237


================
Comment at: clang/test/OpenMP/threadprivate_messages.cpp:141
 label:
-#pragma omp threadprivate(d4) // expected-error {{'#pragma omp threadprivate' cannot be an immediate substatement}}
+#pragma omp threadprivate(d4)
 
----------------
TODO: find out if this is okay? (I've got no idea what it does)


================
Comment at: clang/test/Parser/c2x-label.c:5-6
 void test_label_in_func() {
-    int x;
 label1:
+    int x;
+label2:
----------------
TODO: make sure a warning is printed. I couldn't find correct conditions for the warning, I tried and it produced false positive warnings in some other tests =(

P.S. Its C++'s counterpart: https://github.com/llvm/llvm-project/blob/main/clang/test/Parser/cxx2b-label.cpp


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146393/new/

https://reviews.llvm.org/D146393



More information about the cfe-commits mailing list