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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 20 08:24:28 PDT 2023


aaron.ballman added subscribers: jyu2, mikerice, jdoerfert.
aaron.ballman added inline comments.


================
Comment at: clang/lib/Parse/ParseStmt.cpp:745
     SubStmt = Actions.ActOnNullStmt(ColonLoc);
 
   LabelDecl *LD = Actions.LookupOrCreateLabel(IdentTok.getIdentifierInfo(),
----------------
At this point, you know whether you've parsed a declaration statement or not, so you could potentially add the extension diagnostic logic here.


================
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)
 
----------------
Izaron wrote:
> TODO: find out if this is okay? (I've got no idea what it does)
CC @mikerice @jyu2 @jdoerfert for opinions on OpenMP impact. There are FIXMEs in the code related to this: https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseOpenMP.cpp#L2671


================
Comment at: clang/test/Parser/c2x-label.c:5-6
 void test_label_in_func() {
-    int x;
 label1:
+    int x;
+label2:
----------------
Izaron wrote:
> 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
Yeah, this would be specific to C because C++ has always allowed a declaration there. I left a comment above with a potential idea.


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