From c5d74fe137f6e75c776d79ccaedd58d223bf6d14 Mon Sep 17 00:00:00 2001 From: EbinJose2002 Date: Wed, 25 Jun 2025 14:18:29 +0530 Subject: [PATCH 1/2] Solving issue with c style comments preceding continuation lines Adeed test file for the issue --- flang/lib/Parser/prescan.cpp | 4 ++++ flang/test/Parser/continuation-after-comment.f90 | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 flang/test/Parser/continuation-after-comment.f90 diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp index 9aef0c9981e3c..5c92974e3ebf2 100644 --- a/flang/lib/Parser/prescan.cpp +++ b/flang/lib/Parser/prescan.cpp @@ -1455,6 +1455,10 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) { return nullptr; } } + if (p[0] == '/' && p[1] == '*') { + p = SkipCComment(p); + p = SkipWhiteSpaceIncludingEmptyMacros(p); + } if (p[0] == '!' && p[1] == '$' && !preprocessingOnly_ && features_.IsEnabled(LanguageFeature::OpenMP)) { // !$ conditional line can be a continuation diff --git a/flang/test/Parser/continuation-after-comment.f90 b/flang/test/Parser/continuation-after-comment.f90 new file mode 100644 index 0000000000000..62746f9ad2b4b --- /dev/null +++ b/flang/test/Parser/continuation-after-comment.f90 @@ -0,0 +1,15 @@ +! RUN: %flang_fc1 -E %s 2>&1 | FileCheck %s + +!Checking comments appearing in between continuation lines. +integer & +i(1) +/* \\\*/ +!CHECK: integer i(1) +i(1)& +/* \\\*/ +=1 +!CHECK: i(1) =1 +/* \*/ +if (i(1)/=1)write(6,*)'error',i(1) +print *,'pass' +end \ No newline at end of file From c3444f3db4d4317b84adf68cee594a4a18c294dc Mon Sep 17 00:00:00 2001 From: Ebin-McW Date: Thu, 26 Jun 2025 12:50:46 +0530 Subject: [PATCH 2/2] Update continuation-after-comment.f90 --- flang/test/Parser/continuation-after-comment.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flang/test/Parser/continuation-after-comment.f90 b/flang/test/Parser/continuation-after-comment.f90 index 62746f9ad2b4b..845aa8bc36e5c 100644 --- a/flang/test/Parser/continuation-after-comment.f90 +++ b/flang/test/Parser/continuation-after-comment.f90 @@ -12,4 +12,4 @@ /* \*/ if (i(1)/=1)write(6,*)'error',i(1) print *,'pass' -end \ No newline at end of file +end