[flang-commits] [flang] 13f97f0 - [flang][OpenMP] Simplify LooselyStructuredBlockParser, NFC (#156701)

via flang-commits flang-commits at lists.llvm.org
Thu Sep 4 05:56:01 PDT 2025


Author: Krzysztof Parzyszek
Date: 2025-09-04T07:55:56-05:00
New Revision: 13f97f013adbe7ad0ef2bf3634d14b6fccfae90d

URL: https://github.com/llvm/llvm-project/commit/13f97f013adbe7ad0ef2bf3634d14b6fccfae90d
DIFF: https://github.com/llvm/llvm-project/commit/13f97f013adbe7ad0ef2bf3634d14b6fccfae90d.diff

LOG: [flang][OpenMP] Simplify LooselyStructuredBlockParser, NFC (#156701)

Part of the logic in this parser was dealing with a list of executable
constructs that begins with BLOCK. Since after 6b92a3bc21cdc we're doing
it via a lookahead, this handling can be simplified.

Added: 
    

Modified: 
    flang/lib/Parser/openmp-parsers.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index 1b7665ce4acf5..2bd33883c3b06 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -1307,22 +1307,11 @@ struct LooselyStructuredBlockParser {
     if (lookAhead(skipStuffBeforeStatement >> "BLOCK"_tok).Parse(state)) {
       return std::nullopt;
     }
-    Block body;
-    if (auto epc{attempt(Parser<ExecutionPartConstruct>{}).Parse(state)}) {
-      if (!IsFortranBlockConstruct(*epc)) {
-        body.emplace_back(std::move(*epc));
-        if (auto &&blk{attempt(block).Parse(state)}) {
-          for (auto &&s : *blk) {
-            body.emplace_back(std::move(s));
-          }
-        }
-      } else {
-        // Fail if the first construct is BLOCK.
-        return std::nullopt;
-      }
+    if (auto &&body{block.Parse(state)}) {
+      // Empty body is ok.
+      return std::move(body);
     }
-    // Empty body is ok.
-    return std::move(body);
+    return std::nullopt;
   }
 };
 


        


More information about the flang-commits mailing list