[flang-commits] [flang] [flang] Accept C-style comments in label fields (PR #207012)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Tue Aug 4 10:55:37 PDT 2026


================
@@ -1366,12 +1408,27 @@ const char *Prescanner::FixedFormContinuationLine(bool atNewline) {
   }
   tabInCurrentLine_ = false;
   char col1{*nextLine_};
+  const char *afterWhiteSpace{SkipWhiteSpace(nextLine_)};
----------------
luporl wrote:

As it is implemented, C style comments take precedence over line continuation.
Considering multi-language header files, it would be strange if only C style comments beginning at column 6 were ignored.

But, as the example above shows, some otherwise valid fixed-form Fortran programs would fail to compile.
I think we should follow what GFortran and IFX do: when preprocessing is enabled, make C style comments take precedence. When it is disabled, ignore all C style comments.

GFortran: https://godbolt.org/z/nP4hYxbK6
IFX: https://godbolt.org/z/WGc1TYhn4

In the case of Flang, it already accepts C style comments even with preprocessing disabled, so this could potentially surprise users relying on this. Another option would be to disable C comments only in label fields, that are being supported only now, with this PR.

What do you think?

https://github.com/llvm/llvm-project/pull/207012


More information about the flang-commits mailing list