https://github.com/JDPailleux updated 
https://github.com/llvm/llvm-project/pull/192941

>From 6e7988572c8d6cbb5218230f6087fbe4fd5502dd Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux <[email protected]>
Date: Fri, 17 Apr 2026 14:55:20 +0200
Subject: [PATCH 01/14] [Flang] Adding -ffree-line-length-<value> flag

---
 clang/include/clang/Options/FlangOptions.td   |  6 ++-
 clang/lib/Driver/ToolChains/Flang.cpp         |  1 +
 .../include/flang/Frontend/FrontendOptions.h  |  8 +++-
 flang/include/flang/Parser/options.h          |  1 +
 flang/lib/Frontend/CompilerInvocation.cpp     | 12 ++++--
 flang/lib/Parser/parsing.cpp                  |  1 +
 flang/lib/Parser/prescan.cpp                  |  3 ++
 flang/lib/Parser/prescan.h                    |  5 +++
 .../Driver/Inputs/free-line-length-test.f90   |  4 ++
 flang/test/Driver/ffree-line-length.f90       | 38 +++++++++++++++++++
 10 files changed, 72 insertions(+), 7 deletions(-)
 create mode 100644 flang/test/Driver/Inputs/free-line-length-test.f90
 create mode 100644 flang/test/Driver/ffree-line-length.f90

diff --git a/clang/include/clang/Options/FlangOptions.td 
b/clang/include/clang/Options/FlangOptions.td
index 4fa0d7a9abcc6..1029ef514598a 100644
--- a/clang/include/clang/Options/FlangOptions.td
+++ b/clang/include/clang/Options/FlangOptions.td
@@ -22,7 +22,6 @@ def static_libgfortran : Flag<["-"], "static-libgfortran">, 
Group<gfortran_Group
 def fblas_matmul_limit_EQ : Joined<["-"], "fblas-matmul-limit=">, 
Group<gfortran_Group>;
 def fcheck_EQ : Joined<["-"], "fcheck=">, Group<gfortran_Group>;
 def ffpe_trap_EQ : Joined<["-"], "ffpe-trap=">, Group<gfortran_Group>;
-def ffree_line_length_VALUE : Joined<["-"], "ffree-line-length-">, 
Group<gfortran_Group>;
 def finit_character_EQ : Joined<["-"], "finit-character=">, 
Group<gfortran_Group>;
 def finit_integer_EQ : Joined<["-"], "finit-integer=">, Group<gfortran_Group>;
 def finit_logical_EQ : Joined<["-"], "finit-logical=">, Group<gfortran_Group>;
@@ -148,6 +147,11 @@ def ffixed_line_length_EQ : Joined<["-"], 
"ffixed-line-length=">, Group<f_Group>
   DocBrief<[{Set column after which characters are ignored in typical 
fixed-form lines in the source
 file}]>;
 def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, 
Group<f_Group>, Alias<ffixed_line_length_EQ>;
+def ffree_line_length_EQ : Joined<["-"], "ffree-line-length=">, Group<f_Group>,
+  HelpText<"Use <value> as character line width in free mode">,
+  DocBrief<[{Set column after which characters are ignored in typical 
free-form lines in the source
+file}]>;
+def ffree_line_length_VALUE : Joined<["-"], "ffree-line-length-">, 
Group<f_Group>, Alias<ffree_line_length_EQ>;
 def fconvert_EQ : Joined<["-"], "fconvert=">, Group<f_Group>,
   HelpText<"Set endian conversion of data for unformatted files">;
 def fdefault_double_8 : Flag<["-"],"fdefault-double-8">, Group<f_Group>,
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 4c722a2e021eb..61423425f4dcd 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -40,6 +40,7 @@ void Flang::addFortranDialectOptions(const ArgList &Args,
   Args.addAllArgs(CmdArgs, {options::OPT_ffixed_form,
                             options::OPT_ffree_form,
                             options::OPT_ffixed_line_length_EQ,
+                            options::OPT_ffree_line_length_EQ,
                             options::OPT_fopenacc,
                             options::OPT_finput_charset_EQ,
                             options::OPT_fimplicit_none,
diff --git a/flang/include/flang/Frontend/FrontendOptions.h 
b/flang/include/flang/Frontend/FrontendOptions.h
index 0bd2e621813ca..25683fc25f4b2 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -145,10 +145,10 @@ enum class FortranForm {
   /// The user has not specified a form. Base the form off the file extension.
   Unknown,
 
-  /// -ffree-form
+  /// -ffixed-form
   FixedForm,
 
-  /// -ffixed-form
+  /// -ffree-form
   FreeForm
 };
 
@@ -286,6 +286,10 @@ struct FrontendOptions {
   // source file.
   int fixedFormColumns = 72;
 
+  // The column after which characters are ignored in free form lines in the
+  // source file.
+  int freeFormColumns = 1000000;
+
   /// The input kind, either specified via -x argument or deduced from the 
input
   /// file name.
   InputKind dashX;
diff --git a/flang/include/flang/Parser/options.h 
b/flang/include/flang/Parser/options.h
index e65f253748d26..6db23dcb6bf07 100644
--- a/flang/include/flang/Parser/options.h
+++ b/flang/include/flang/Parser/options.h
@@ -25,6 +25,7 @@ struct Options {
 
   bool isFixedForm{false};
   int fixedFormColumns{72};
+  int freeFormColumns{1000000};
   common::LanguageFeatureControl features;
   std::vector<std::string> searchDirectories;
   std::vector<std::string> intrinsicModuleDirectories;
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 9853fc600ff6a..ec95a83ff2568 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -809,7 +809,8 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
 
   // Set fixedFormColumns based on -ffixed-line-length=<value>
   if (const auto *arg =
-          args.getLastArg(clang::options::OPT_ffixed_line_length_EQ)) {
+          args.getLastArg(clang::options::OPT_ffixed_line_length_EQ,
+                          clang::options::OPT_ffree_line_length_EQ)) {
     llvm::StringRef argValue = llvm::StringRef(arg->getValue());
     std::int64_t columns = -1;
     if (argValue == "none") {
@@ -821,13 +822,15 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
       diags.Report(clang::diag::err_drv_negative_columns)
           << arg->getOption().getName() << arg->getValue();
     } else if (columns == 0) {
-      opts.fixedFormColumns = 1000000;
+      columns = 1000000;
     } else if (columns < 7) {
       diags.Report(clang::diag::err_drv_small_columns)
           << arg->getOption().getName() << arg->getValue() << "7";
-    } else {
-      opts.fixedFormColumns = columns;
     }
+    if (arg->getOption().matches(clang::options::OPT_ffixed_line_length_EQ))
+      opts.fixedFormColumns = columns;
+    else
+      opts.freeFormColumns = columns;
   }
 
   // Set conversion based on -fconvert=<value>
@@ -1890,6 +1893,7 @@ void CompilerInvocation::setFortranOpts() {
         frontendOptions.fortranForm == FortranForm::FixedForm;
   }
   fortranOptions.fixedFormColumns = frontendOptions.fixedFormColumns;
+  fortranOptions.freeFormColumns = frontendOptions.freeFormColumns;
 
   // -E
   fortranOptions.prescanAndReformat =
diff --git a/flang/lib/Parser/parsing.cpp b/flang/lib/Parser/parsing.cpp
index 667d8d9297ecb..3bdbcb3fd1281 100644
--- a/flang/lib/Parser/parsing.cpp
+++ b/flang/lib/Parser/parsing.cpp
@@ -75,6 +75,7 @@ const SourceFile *Parsing::Prescan(const std::string &path, 
Options options) {
       messages_, *currentCooked_, preprocessor_, options.features};
   prescanner.set_fixedForm(options.isFixedForm)
       .set_fixedFormColumnLimit(options.fixedFormColumns)
+      .set_freeFormColumnLimit(options.freeFormColumns)
       .set_preprocessingOnly(options.prescanAndReformat)
       .set_expandIncludeLines(!options.prescanAndReformat ||
           options.expandIncludeLinesInPreprocessedOutput)
diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index c1dd17400012a..952c2f3cb4a86 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -42,6 +42,7 @@ Prescanner::Prescanner(const Prescanner &that, Preprocessor 
&prepro,
       backslashFreeFormContinuation_{that.backslashFreeFormContinuation_},
       inFixedForm_{that.inFixedForm_},
       fixedFormColumnLimit_{that.fixedFormColumnLimit_},
+      freeFormColumnLimit_{that.freeFormColumnLimit_},
       encoding_{that.encoding_},
       prescannerNesting_{that.prescannerNesting_ + 1},
       skipLeadingAmpersand_{that.skipLeadingAmpersand_},
@@ -568,6 +569,8 @@ void Prescanner::SkipToEndOfLine() {
 bool Prescanner::MustSkipToEndOfLine() const {
   if (inFixedForm_ && column_ > fixedFormColumnLimit_ && !tabInCurrentLine_) {
     return true; // skip over ignored columns in right margin (73:80)
+  } else if (!inFixedForm_ && column_ > freeFormColumnLimit_) {
+    return true; // inline comment goes to end of source line
   } else if (*at_ == '!' && !inCharLiteral_ &&
       (!inFixedForm_ || tabInCurrentLine_ || column_ != 6)) {
     return InCompilerDirective() ||
diff --git a/flang/lib/Parser/prescan.h b/flang/lib/Parser/prescan.h
index 8f4f390d4ea37..2e511e4edf71e 100644
--- a/flang/lib/Parser/prescan.h
+++ b/flang/lib/Parser/prescan.h
@@ -68,6 +68,10 @@ class Prescanner {
     fixedFormColumnLimit_ = limit;
     return *this;
   }
+  Prescanner &set_freeFormColumnLimit(int limit) {
+    freeFormColumnLimit_ = limit;
+    return *this;
+  }
 
   Prescanner &AddCompilerDirectiveSentinel(const std::string &);
 
@@ -269,6 +273,7 @@ class Prescanner {
   bool backslashFreeFormContinuation_{false};
   bool inFixedForm_{false};
   int fixedFormColumnLimit_{72};
+  int freeFormColumnLimit_{1000000};
   Encoding encoding_{Encoding::UTF_8};
   int parenthesisNesting_{0};
   int prescannerNesting_{0};
diff --git a/flang/test/Driver/Inputs/free-line-length-test.f90 
b/flang/test/Driver/Inputs/free-line-length-test.f90
new file mode 100644
index 0000000000000..dda2245ed34ce
--- /dev/null
+++ b/flang/test/Driver/Inputs/free-line-length-test.f90
@@ -0,0 +1,4 @@
+! The length of the line below is exactly 133 characters
+      program 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+      end
+
diff --git a/flang/test/Driver/ffree-line-length.f90 
b/flang/test/Driver/ffree-line-length.f90
new file mode 100644
index 0000000000000..9e54191181092
--- /dev/null
+++ b/flang/test/Driver/ffree-line-length.f90
@@ -0,0 +1,38 @@
+! Ensure argument -ffree-line-length=n works as expected.
+
+!--------------------------
+! FLANG DRIVER (flang)
+!--------------------------
+! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/free-line-length-test.f90  
2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length=-2 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=NEGATIVELENGTH
+! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length=3 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
+! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=none 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
+! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=0 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
+! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=13 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+!----------------------------------------
+! FRONTEND FLANG DRIVER (flang -fc1)
+!----------------------------------------
+! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/free-line-length-test.f90  2>&1 | 
FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: not %flang_fc1 -E -fno-reformat -ffree-line-length=-2 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=NEGATIVELENGTH
+! RUN: not %flang_fc1 -E -fno-reformat -ffree-line-length=3 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
+! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=none 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
+! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=0 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
+! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=13 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+!-------------------------------------
+! COMMAND ALIAS -ffree-line-length-n
+!-------------------------------------
+! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length-13 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s --check-prefix=LENGTH13
+! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length-13 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+
+! NEGATIVELENGTH: invalid value '-2' in 'ffree-line-length=', value must be 
'none' or a positive integer
+
+! INVALIDLENGTH: invalid value '3' in 'ffree-line-length=', value must be '7' 
or greater
+
+! The line should not be trimmed and should be read.
+! UNLIMITEDLENGTH: program {{(a{118})}}
+
+! LENGTH13: program
+

>From c91aac75b814d1eb54888b6d488ae88bfe307ff0 Mon Sep 17 00:00:00 2001
From: Jean-Didier PAILLEUX <[email protected]>
Date: Tue, 21 Apr 2026 11:22:52 +0200
Subject: [PATCH 02/14] Update clang/include/clang/Options/Options.td

Co-authored-by: Tarun Prabhu <[email protected]>
---
 clang/include/clang/Options/FlangOptions.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Options/FlangOptions.td 
b/clang/include/clang/Options/FlangOptions.td
index 1029ef514598a..8c94be429ca72 100644
--- a/clang/include/clang/Options/FlangOptions.td
+++ b/clang/include/clang/Options/FlangOptions.td
@@ -148,7 +148,7 @@ def ffixed_line_length_EQ : Joined<["-"], 
"ffixed-line-length=">, Group<f_Group>
 file}]>;
 def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, 
Group<f_Group>, Alias<ffixed_line_length_EQ>;
 def ffree_line_length_EQ : Joined<["-"], "ffree-line-length=">, Group<f_Group>,
-  HelpText<"Use <value> as character line width in free mode">,
+  HelpText<"Use <value> as the maximum line width in free-form mode">,
   DocBrief<[{Set column after which characters are ignored in typical 
free-form lines in the source
 file}]>;
 def ffree_line_length_VALUE : Joined<["-"], "ffree-line-length-">, 
Group<f_Group>, Alias<ffree_line_length_EQ>;

>From 876eca4b122eb2591e543d360bcb769ac0b2dbb4 Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux <[email protected]>
Date: Tue, 21 Apr 2026 13:30:08 +0200
Subject: [PATCH 03/14] Applying feedback and Update freeFormColums value based
 on 6.3.2.1

---
 flang/include/flang/Frontend/FrontendOptions.h |  4 +++-
 flang/lib/Frontend/CompilerInvocation.cpp      | 10 +++++++---
 flang/lib/Parser/prescan.cpp                   |  2 +-
 flang/test/Driver/ffree-line-length.f90        |  6 +++---
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/flang/include/flang/Frontend/FrontendOptions.h 
b/flang/include/flang/Frontend/FrontendOptions.h
index 25683fc25f4b2..8149cb444f619 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -288,7 +288,9 @@ struct FrontendOptions {
 
   // The column after which characters are ignored in free form lines in the
   // source file.
-  int freeFormColumns = 1000000;
+  // In 6.3.2.1, in free source form a line shall contain at most ten thousand
+  // characters.
+  int freeFormColumns = 10000;
 
   /// The input kind, either specified via -x argument or deduced from the 
input
   /// file name.
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index ec95a83ff2568..fbda0906b8d0f 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -807,11 +807,14 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
                            : FortranForm::FreeForm;
   }
 
-  // Set fixedFormColumns based on -ffixed-line-length=<value>
+  // Set fixedFormColumns based on -ffixed-line-length=<value> or
+  // set freeFormColumns based on -ffree-line-length=<value>.
   if (const auto *arg =
           args.getLastArg(clang::options::OPT_ffixed_line_length_EQ,
                           clang::options::OPT_ffree_line_length_EQ)) {
     llvm::StringRef argValue = llvm::StringRef(arg->getValue());
+    bool isFixedLineFlag =
+        arg->getOption().matches(clang::options::OPT_ffixed_line_length_EQ);
     std::int64_t columns = -1;
     if (argValue == "none") {
       columns = 0;
@@ -823,11 +826,12 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
           << arg->getOption().getName() << arg->getValue();
     } else if (columns == 0) {
       columns = 1000000;
-    } else if (columns < 7) {
+    } else if (columns < 7 && isFixedLineFlag) {
+      // Specific to the fixed form
       diags.Report(clang::diag::err_drv_small_columns)
           << arg->getOption().getName() << arg->getValue() << "7";
     }
-    if (arg->getOption().matches(clang::options::OPT_ffixed_line_length_EQ))
+    if (isFixedLineFlag)
       opts.fixedFormColumns = columns;
     else
       opts.freeFormColumns = columns;
diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 952c2f3cb4a86..231fb63162cca 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -570,7 +570,7 @@ bool Prescanner::MustSkipToEndOfLine() const {
   if (inFixedForm_ && column_ > fixedFormColumnLimit_ && !tabInCurrentLine_) {
     return true; // skip over ignored columns in right margin (73:80)
   } else if (!inFixedForm_ && column_ > freeFormColumnLimit_) {
-    return true; // inline comment goes to end of source line
+    return true;
   } else if (*at_ == '!' && !inCharLiteral_ &&
       (!inFixedForm_ || tabInCurrentLine_ || column_ != 6)) {
     return InCompilerDirective() ||
diff --git a/flang/test/Driver/ffree-line-length.f90 
b/flang/test/Driver/ffree-line-length.f90
index 9e54191181092..54a5f03a1f4d5 100644
--- a/flang/test/Driver/ffree-line-length.f90
+++ b/flang/test/Driver/ffree-line-length.f90
@@ -5,7 +5,7 @@
 !--------------------------
 ! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/free-line-length-test.f90  
2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
 ! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length=-2 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=NEGATIVELENGTH
-! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length=3 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
+! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length-abcd 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
 ! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=none 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=0 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=13 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s --check-prefix=LENGTH13
@@ -15,7 +15,7 @@
 !----------------------------------------
 ! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/free-line-length-test.f90  2>&1 | 
FileCheck %s --check-prefix=UNLIMITEDLENGTH
 ! RUN: not %flang_fc1 -E -fno-reformat -ffree-line-length=-2 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=NEGATIVELENGTH
-! RUN: not %flang_fc1 -E -fno-reformat -ffree-line-length=3 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
+! RUN: not %flang_fc1 -E -fno-reformat -ffree-line-length-abcd 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
 ! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=none 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=0 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=13 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s --check-prefix=LENGTH13
@@ -29,7 +29,7 @@
 
 ! NEGATIVELENGTH: invalid value '-2' in 'ffree-line-length=', value must be 
'none' or a positive integer
 
-! INVALIDLENGTH: invalid value '3' in 'ffree-line-length=', value must be '7' 
or greater
+! INVALIDLENGTH: invalid value 'abcd' in 'ffree-line-length=', value must be 
'none' or a positive integer
 
 ! The line should not be trimmed and should be read.
 ! UNLIMITEDLENGTH: program {{(a{118})}}

>From 22444f42dc99b924a86d7f6a4473ebe9049476fb Mon Sep 17 00:00:00 2001
From: Jean-Didier PAILLEUX <[email protected]>
Date: Tue, 21 Apr 2026 17:07:30 +0200
Subject: [PATCH 04/14] Update flang/include/flang/Frontend/FrontendOptions.h

Co-authored-by: Tarun Prabhu <[email protected]>
---
 flang/include/flang/Frontend/FrontendOptions.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/include/flang/Frontend/FrontendOptions.h 
b/flang/include/flang/Frontend/FrontendOptions.h
index 8149cb444f619..93aec9dec204c 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -288,7 +288,7 @@ struct FrontendOptions {
 
   // The column after which characters are ignored in free form lines in the
   // source file.
-  // In 6.3.2.1, in free source form a line shall contain at most ten thousand
+  // In 6.3.2.1, in free form source a line shall contain at most ten thousand
   // characters.
   int freeFormColumns = 10000;
 

>From ee8944f4d2ea61dda7a55bbef1a3c24bcb009ed0 Mon Sep 17 00:00:00 2001
From: Jean-Didier PAILLEUX <[email protected]>
Date: Tue, 21 Apr 2026 17:08:19 +0200
Subject: [PATCH 05/14] Update clang/include/clang/Options/Options.td

Co-authored-by: Tarun Prabhu <[email protected]>
---
 clang/include/clang/Options/FlangOptions.td | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Options/FlangOptions.td 
b/clang/include/clang/Options/FlangOptions.td
index 8c94be429ca72..7c9c3e97414c8 100644
--- a/clang/include/clang/Options/FlangOptions.td
+++ b/clang/include/clang/Options/FlangOptions.td
@@ -149,7 +149,7 @@ file}]>;
 def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, 
Group<f_Group>, Alias<ffixed_line_length_EQ>;
 def ffree_line_length_EQ : Joined<["-"], "ffree-line-length=">, Group<f_Group>,
   HelpText<"Use <value> as the maximum line width in free-form mode">,
-  DocBrief<[{Set column after which characters are ignored in typical 
free-form lines in the source
+  DocBrief<[{Set column after which characters are ignored in free-form lines 
in the source
 file}]>;
 def ffree_line_length_VALUE : Joined<["-"], "ffree-line-length-">, 
Group<f_Group>, Alias<ffree_line_length_EQ>;
 def fconvert_EQ : Joined<["-"], "fconvert=">, Group<f_Group>,

>From 4a252f60f60d8590b5833145a7030b9d92606449 Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux <[email protected]>
Date: Wed, 22 Apr 2026 09:30:36 +0200
Subject: [PATCH 06/14] Update values of default column value + err message
 name

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 2 +-
 flang/include/flang/Frontend/FrontendOptions.h     | 4 ++--
 flang/include/flang/Parser/options.h               | 2 +-
 flang/lib/Frontend/CompilerInvocation.cpp          | 4 ++--
 flang/test/Driver/Inputs/free-line-length-test.f90 | 6 +++---
 flang/test/Driver/ffree-line-length.f90            | 4 ++--
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 020014dabacfd..10238eee2a49c 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -422,7 +422,7 @@ def err_drv_unsupported_embed_bitcode
     : Error<"%0 is not supported with -fembed-bitcode">;
 def err_drv_bitcode_unsupported_on_toolchain : Error<
   "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
-def err_drv_negative_columns : Error<
+def err_drv_invalid_columns : Error<
   "invalid value '%1' in '%0', value must be 'none' or a positive integer">;
 def err_drv_small_columns : Error<
   "invalid value '%1' in '%0', value must be '%2' or greater">;
diff --git a/flang/include/flang/Frontend/FrontendOptions.h 
b/flang/include/flang/Frontend/FrontendOptions.h
index 93aec9dec204c..409a88a7e50e4 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -288,8 +288,8 @@ struct FrontendOptions {
 
   // The column after which characters are ignored in free form lines in the
   // source file.
-  // In 6.3.2.1, in free form source a line shall contain at most ten thousand
-  // characters.
+  // In F2023 6.3.2.1 p1, in free form source a line shall contain at most ten
+  // thousand characters.
   int freeFormColumns = 10000;
 
   /// The input kind, either specified via -x argument or deduced from the 
input
diff --git a/flang/include/flang/Parser/options.h 
b/flang/include/flang/Parser/options.h
index 6db23dcb6bf07..adb01ae72639f 100644
--- a/flang/include/flang/Parser/options.h
+++ b/flang/include/flang/Parser/options.h
@@ -25,7 +25,7 @@ struct Options {
 
   bool isFixedForm{false};
   int fixedFormColumns{72};
-  int freeFormColumns{1000000};
+  int freeFormColumns{10000};
   common::LanguageFeatureControl features;
   std::vector<std::string> searchDirectories;
   std::vector<std::string> intrinsicModuleDirectories;
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index fbda0906b8d0f..f5662a8e4836b 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -822,10 +822,10 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
       columns = -1;
     }
     if (columns < 0) {
-      diags.Report(clang::diag::err_drv_negative_columns)
+      diags.Report(clang::diag::err_drv_invalid_columns)
           << arg->getOption().getName() << arg->getValue();
     } else if (columns == 0) {
-      columns = 1000000;
+      columns = 10000;
     } else if (columns < 7 && isFixedLineFlag) {
       // Specific to the fixed form
       diags.Report(clang::diag::err_drv_small_columns)
diff --git a/flang/test/Driver/Inputs/free-line-length-test.f90 
b/flang/test/Driver/Inputs/free-line-length-test.f90
index dda2245ed34ce..5eadb19c378ae 100644
--- a/flang/test/Driver/Inputs/free-line-length-test.f90
+++ b/flang/test/Driver/Inputs/free-line-length-test.f90
@@ -1,4 +1,4 @@
-! The length of the line below is exactly 133 characters
-      program 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-      end
+! The length of the line below is exactly 35 characters
+program arbitrary_program_test_name 
+end
 
diff --git a/flang/test/Driver/ffree-line-length.f90 
b/flang/test/Driver/ffree-line-length.f90
index 54a5f03a1f4d5..0d1b58855332e 100644
--- a/flang/test/Driver/ffree-line-length.f90
+++ b/flang/test/Driver/ffree-line-length.f90
@@ -32,7 +32,7 @@
 ! INVALIDLENGTH: invalid value 'abcd' in 'ffree-line-length=', value must be 
'none' or a positive integer
 
 ! The line should not be trimmed and should be read.
-! UNLIMITEDLENGTH: program {{(a{118})}}
+! UNLIMITEDLENGTH: program arbitrary_program_test_name
 
-! LENGTH13: program
+! LENGTH13: program arbit
 

>From 77814fe39b20c99b4dd73a4ccc461a906cbcc7e6 Mon Sep 17 00:00:00 2001
From: Jean-Didier PAILLEUX <[email protected]>
Date: Thu, 23 Apr 2026 14:29:53 +0200
Subject: [PATCH 07/14] Update
 flang/test/Driver/Inputs/free-line-length-test.f90

Co-authored-by: Tarun Prabhu <[email protected]>
---
 flang/test/Driver/Inputs/free-line-length-test.f90 | 1 -
 1 file changed, 1 deletion(-)

diff --git a/flang/test/Driver/Inputs/free-line-length-test.f90 
b/flang/test/Driver/Inputs/free-line-length-test.f90
index 5eadb19c378ae..d436ffedcda32 100644
--- a/flang/test/Driver/Inputs/free-line-length-test.f90
+++ b/flang/test/Driver/Inputs/free-line-length-test.f90
@@ -1,4 +1,3 @@
 ! The length of the line below is exactly 35 characters
 program arbitrary_program_test_name 
 end
-

>From c6ebaeff90061b053a5b79e4b2a310a072549dcb Mon Sep 17 00:00:00 2001
From: Jean-Didier PAILLEUX <[email protected]>
Date: Thu, 23 Apr 2026 14:32:56 +0200
Subject: [PATCH 08/14] Update flang/test/Driver/ffree-line-length.f90

Co-authored-by: Tarun Prabhu <[email protected]>
---
 flang/test/Driver/ffree-line-length.f90 | 1 -
 1 file changed, 1 deletion(-)

diff --git a/flang/test/Driver/ffree-line-length.f90 
b/flang/test/Driver/ffree-line-length.f90
index 0d1b58855332e..ed66de6e75449 100644
--- a/flang/test/Driver/ffree-line-length.f90
+++ b/flang/test/Driver/ffree-line-length.f90
@@ -35,4 +35,3 @@
 ! UNLIMITEDLENGTH: program arbitrary_program_test_name
 
 ! LENGTH13: program arbit
-

>From 6cf5da99279df661cf26acd7556ccae2456a09b5 Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux <[email protected]>
Date: Thu, 23 Apr 2026 16:01:38 +0200
Subject: [PATCH 09/14] Update value freeFormColumnLimit

---
 flang/lib/Parser/prescan.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/lib/Parser/prescan.h b/flang/lib/Parser/prescan.h
index 2e511e4edf71e..519ff01041ba5 100644
--- a/flang/lib/Parser/prescan.h
+++ b/flang/lib/Parser/prescan.h
@@ -273,7 +273,7 @@ class Prescanner {
   bool backslashFreeFormContinuation_{false};
   bool inFixedForm_{false};
   int fixedFormColumnLimit_{72};
-  int freeFormColumnLimit_{1000000};
+  int freeFormColumnLimit_{10000};
   Encoding encoding_{Encoding::UTF_8};
   int parenthesisNesting_{0};
   int prescannerNesting_{0};

>From c05a007c85e0126a8b2b06837b5de5fe765a67f8 Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux <[email protected]>
Date: Wed, 29 Apr 2026 22:09:19 +0200
Subject: [PATCH 10/14] Update if constuct to 1 line

---
 flang/lib/Frontend/CompilerInvocation.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index f5662a8e4836b..9f0529c592d25 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -831,10 +831,8 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
       diags.Report(clang::diag::err_drv_small_columns)
           << arg->getOption().getName() << arg->getValue() << "7";
     }
-    if (isFixedLineFlag)
-      opts.fixedFormColumns = columns;
-    else
-      opts.freeFormColumns = columns;
+
+    (isFixedLineFlag ? opts.fixedFormColumns : opts.freeFormColumns) = columns;
   }
 
   // Set conversion based on -fconvert=<value>

>From 97b3123fdfa4edc84f2337c8f135cc2553c6d78a Mon Sep 17 00:00:00 2001
From: Jean-Didier PAILLEUX <[email protected]>
Date: Mon, 4 May 2026 15:21:07 +0200
Subject: [PATCH 11/14] Update flang/test/Driver/ffree-line-length.f90

Co-authored-by: Andre Kuhlenschmidt <[email protected]>
---
 flang/test/Driver/ffree-line-length.f90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/test/Driver/ffree-line-length.f90 
b/flang/test/Driver/ffree-line-length.f90
index ed66de6e75449..a705098132a41 100644
--- a/flang/test/Driver/ffree-line-length.f90
+++ b/flang/test/Driver/ffree-line-length.f90
@@ -5,7 +5,7 @@
 !--------------------------
 ! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/free-line-length-test.f90  
2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
 ! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length=-2 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=NEGATIVELENGTH
-! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length-abcd 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
+! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length=abcd 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
 ! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=none 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=0 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=13 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s --check-prefix=LENGTH13

>From 4050ead787793405c82e126e9f41c1f24a068f25 Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux <[email protected]>
Date: Mon, 4 May 2026 16:53:23 +0200
Subject: [PATCH 12/14] Update test + Update CompilerInvocation with
 args.filtered on free/fixed-line-length flags

---
 flang/lib/Frontend/CompilerInvocation.cpp     |  7 ++--
 .../Driver/Inputs/free-line-length-test.f90   |  3 --
 flang/test/Driver/ffree-line-length.f90       | 41 ++++++++++++-------
 3 files changed, 30 insertions(+), 21 deletions(-)
 delete mode 100644 flang/test/Driver/Inputs/free-line-length-test.f90

diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 9f0529c592d25..efe0a3a506d83 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -809,9 +809,10 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
 
   // Set fixedFormColumns based on -ffixed-line-length=<value> or
   // set freeFormColumns based on -ffree-line-length=<value>.
-  if (const auto *arg =
-          args.getLastArg(clang::options::OPT_ffixed_line_length_EQ,
-                          clang::options::OPT_ffree_line_length_EQ)) {
+  for (const auto *arg :
+       args.filtered(clang::options::OPT_ffixed_line_length_EQ,
+                     clang::options::OPT_ffree_line_length_EQ)) {
+
     llvm::StringRef argValue = llvm::StringRef(arg->getValue());
     bool isFixedLineFlag =
         arg->getOption().matches(clang::options::OPT_ffixed_line_length_EQ);
diff --git a/flang/test/Driver/Inputs/free-line-length-test.f90 
b/flang/test/Driver/Inputs/free-line-length-test.f90
deleted file mode 100644
index d436ffedcda32..0000000000000
--- a/flang/test/Driver/Inputs/free-line-length-test.f90
+++ /dev/null
@@ -1,3 +0,0 @@
-! The length of the line below is exactly 35 characters
-program arbitrary_program_test_name 
-end
diff --git a/flang/test/Driver/ffree-line-length.f90 
b/flang/test/Driver/ffree-line-length.f90
index a705098132a41..4168349e48496 100644
--- a/flang/test/Driver/ffree-line-length.f90
+++ b/flang/test/Driver/ffree-line-length.f90
@@ -3,35 +3,46 @@
 !--------------------------
 ! FLANG DRIVER (flang)
 !--------------------------
-! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/free-line-length-test.f90  
2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
-! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length=-2 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=NEGATIVELENGTH
-! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length=abcd 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
-! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=none 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
-! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=0 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
-! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=13 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s --check-prefix=LENGTH13
+! RUN: %flang -E -Xflang -fno-reformat %s  2>&1 | FileCheck %s 
--check-prefix=LENGTH35
+! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length=-2 %s  2>&1 | 
FileCheck %s --check-prefix=NEGATIVELENGTH
+! RUN: not %flang -E -Xflang -fno-reformat -ffree-line-length=abcd %s  2>&1 | 
FileCheck %s --check-prefix=INVALIDLENGTH
+! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=none %s  2>&1 | 
FileCheck %s --check-prefix=LENGTH35
+! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=0 %s  2>&1 | 
FileCheck %s --check-prefix=LENGTH35
+! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=13 %s  2>&1 | 
FileCheck %s --check-prefix=LENGTH13
 
 !----------------------------------------
 ! FRONTEND FLANG DRIVER (flang -fc1)
 !----------------------------------------
-! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/free-line-length-test.f90  2>&1 | 
FileCheck %s --check-prefix=UNLIMITEDLENGTH
-! RUN: not %flang_fc1 -E -fno-reformat -ffree-line-length=-2 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=NEGATIVELENGTH
-! RUN: not %flang_fc1 -E -fno-reformat -ffree-line-length-abcd 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
-! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=none 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
-! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=0 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
-! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=13 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s --check-prefix=LENGTH13
+! RUN: %flang_fc1 -E -fno-reformat %s  2>&1 | FileCheck %s 
--check-prefix=LENGTH35
+! RUN: not %flang_fc1 -E -fno-reformat -ffree-line-length=-2 %s  2>&1 | 
FileCheck %s --check-prefix=NEGATIVELENGTH
+! RUN: not %flang_fc1 -E -fno-reformat -ffree-line-length-abcd %s  2>&1 | 
FileCheck %s --check-prefix=INVALIDLENGTH
+! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=none %s  2>&1 | 
FileCheck %s --check-prefix=LENGTH35
+! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=0 %s  2>&1 | FileCheck 
%s --check-prefix=LENGTH35
+! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length=13 %s  2>&1 | FileCheck 
%s --check-prefix=LENGTH13
 
 !-------------------------------------
 ! COMMAND ALIAS -ffree-line-length-n
 !-------------------------------------
-! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length-13 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s --check-prefix=LENGTH13
-! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length-13 
%S/Inputs/free-line-length-test.f90  2>&1 | FileCheck %s --check-prefix=LENGTH13
+! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length-13 %s  2>&1 | 
FileCheck %s --check-prefix=LENGTH13
+! RUN: %flang_fc1 -E -fno-reformat -ffree-line-length-13 %s  2>&1 | FileCheck 
%s --check-prefix=LENGTH13
 
+!-------------------------------------
+! BOTH FLAGS
+!-------------------------------------
+! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length=13 
-ffree-line-length=500 %s  2>&1 | FileCheck %s --check-prefix=LENGTH35
+! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=500 
-ffixed-line-length=13 %s  2>&1 | FileCheck %s --check-prefix=LENGTH35
+! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length=100 
-ffree-line-length=13 %s  2>&1 | FileCheck %s --check-prefix=LENGTH13
+! RUN: %flang -E -Xflang -fno-reformat -ffree-line-length=13 
-ffixed-line-length=100 %s  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+! The length of the line below is exactly 35 characters
+program arbitrary_program_test_name 
+end
 
 ! NEGATIVELENGTH: invalid value '-2' in 'ffree-line-length=', value must be 
'none' or a positive integer
 
 ! INVALIDLENGTH: invalid value 'abcd' in 'ffree-line-length=', value must be 
'none' or a positive integer
 
 ! The line should not be trimmed and should be read.
-! UNLIMITEDLENGTH: program arbitrary_program_test_name
+! LENGTH35: program arbitrary_program_test_name
 
 ! LENGTH13: program arbit

>From ec25ba74484a3a9378c8b9423a5fc124649bf9be Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux <[email protected]>
Date: Tue, 5 May 2026 13:08:28 +0200
Subject: [PATCH 13/14] Adding 0 as a sentinel

---
 flang/lib/Parser/prescan.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 231fb63162cca..45e9806eee6bf 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -569,7 +569,8 @@ void Prescanner::SkipToEndOfLine() {
 bool Prescanner::MustSkipToEndOfLine() const {
   if (inFixedForm_ && column_ > fixedFormColumnLimit_ && !tabInCurrentLine_) {
     return true; // skip over ignored columns in right margin (73:80)
-  } else if (!inFixedForm_ && column_ > freeFormColumnLimit_) {
+  } else if (!inFixedForm_ && (freeFormColumnLimit_ != 0) &&
+      column_ > freeFormColumnLimit_) {
     return true;
   } else if (*at_ == '!' && !inCharLiteral_ &&
       (!inFixedForm_ || tabInCurrentLine_ || column_ != 6)) {

>From be7d7c81bf7472549ede268af3f81e8ed39342b8 Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux <[email protected]>
Date: Fri, 8 May 2026 22:29:02 +0200
Subject: [PATCH 14/14] Previous value used for fixed form when column is 0 +
 in free form column is not changed.

---
 flang/lib/Frontend/CompilerInvocation.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index efe0a3a506d83..9e868d8d8a0f1 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -825,8 +825,8 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
     if (columns < 0) {
       diags.Report(clang::diag::err_drv_invalid_columns)
           << arg->getOption().getName() << arg->getValue();
-    } else if (columns == 0) {
-      columns = 10000;
+    } else if (columns == 0 && isFixedLineFlag) {
+      columns = 1000000;
     } else if (columns < 7 && isFixedLineFlag) {
       // Specific to the fixed form
       diags.Report(clang::diag::err_drv_small_columns)

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to