Skip to content

Conversation

kparzysz
Copy link
Contributor

@kparzysz kparzysz commented Sep 3, 2025

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

Part of the logic in this parser was dealing with a list of executable
constructs that begins with BLOCK. Since after 6b92a3b we're doing
it via a lookahead, this handling can be simplified.
@kparzysz kparzysz requested review from tblah and Stylie777 September 3, 2025 15:41
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:parser labels Sep 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 3, 2025

@llvm/pr-subscribers-flang-parser

Author: Krzysztof Parzyszek (kparzysz)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/156701.diff

1 Files Affected:

  • (modified) flang/lib/Parser/openmp-parsers.cpp (+4-15)
diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index cc4e59d318bbe..f9ba5b4c72f39 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;
   }
 };
 

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@kparzysz kparzysz merged commit 13f97f0 into llvm:main Sep 4, 2025
12 checks passed
@kparzysz kparzysz deleted the users/kparzysz/loose-block branch September 4, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:parser flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants