[flang-commits] [flang] [Flang][OpenMP] Fix compilation error when a line with Fixed Source Form Conditional Compilation Sentinels is a continuation line (PR #70309)

via flang-commits flang-commits at lists.llvm.org
Thu Oct 26 01:55:21 PDT 2023


https://github.com/sihuan created https://github.com/llvm/llvm-project/pull/70309

Fixes #67947 

>From 3648e97238c7d1e15ac0a4357a6f3ebe58b835d8 Mon Sep 17 00:00:00 2001
From: SiHuaN <liyongtai at iscas.ac.cn>
Date: Thu, 26 Oct 2023 16:45:22 +0800
Subject: [PATCH] [Flang][OpenMP] Fix compilation error when a line with Fixed
 Source Form Conditional Compilation Sentinels is a continuation line

---
 flang/lib/Parser/prescan.cpp | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 2f25b02bf7a323d..d0495df2d634845 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -997,14 +997,13 @@ const char *Prescanner::FixedFormContinuationLine(bool mightNeedSpace) {
   }
   tabInCurrentLine_ = false;
   char col1{*nextLine_};
-  if (InCompilerDirective()) {
+  LineClassification nextLine{ClassifyLine(nextLine_)};
+  if (nextLine.kind ==
+      LineClassification::Kind::CompilerDirective) {
     // Must be a continued compiler directive.
-    if (!IsFixedFormCommentChar(col1)) {
-      return nullptr;
-    }
     int j{1};
     for (; j < 5; ++j) {
-      char ch{directiveSentinel_[j - 1]};
+      char ch{nextLine.sentinel[j - 1]};
       if (ch == '\0') {
         break;
       }
@@ -1192,8 +1191,7 @@ Prescanner::IsFixedFormCompilerDirectiveLine(const char *start) const {
     if (*p == ' ' || *p == '\t' || *p == '0') {
       ++p;
     } else {
-      // This is a Continuation line, not an initial directive line.
-      return std::nullopt;
+      // This is a Continued compiler directive.
     }
   }
   if (sp == sentinel) {



More information about the flang-commits mailing list