https://github.com/Popie52 updated 
https://github.com/llvm/llvm-project/pull/229972

>From 6e9f64d74e009a90f583d8a8b47f0d76ba67aac6 Mon Sep 17 00:00:00 2001
From: popie52 <[email protected]>
Date: Thu, 8 Oct 2026 07:49:30 +0530
Subject: [PATCH 1/2] [flang] Reject oversized -ffixed-line-length values

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 2 ++
 flang/lib/Frontend/CompilerInvocation.cpp          | 5 +++++
 flang/test/Driver/fixed-line-length.f90            | 4 ++++
 3 files changed, 11 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index df6ff0c2cf399..a072abd463e08 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -443,6 +443,8 @@ def err_drv_negative_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">;
+def err_drv_large_columns : Error<
+  "invalid value '%1' in '%0', value must be '%2' or smaller">;
 def warn_drv_fraw_string_literals_in_cxx11 : Warning<
   "ignoring '-f%select{no-|}0raw-string-literals', which is only valid for C 
and C++ standards before C++11">,
   InGroup<UnusedCommandLineArgument>;
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index 13794f5720e74..17fe9dc9a8a3f 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -46,6 +46,7 @@
 #include "llvm/TargetParser/Triple.h"
 #include <algorithm>
 #include <cstdlib>
+#include <limits>
 #include <memory>
 #include <optional>
 
@@ -879,6 +880,10 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
     } else if (columns < 7) {
       diags.Report(clang::diag::err_drv_small_columns)
           << arg->getOption().getName() << arg->getValue() << "7";
+    } else if (columns > std::numeric_limits<int>::max()) {
+      diags.Report(clang::diag::err_drv_large_columns)
+          << arg->getOption().getName() << arg->getValue()
+          << std::numeric_limits<int>::max();
     } else {
       opts.fixedFormColumns = columns;
     }
diff --git a/flang/test/Driver/fixed-line-length.f90 
b/flang/test/Driver/fixed-line-length.f90
index 879b7de7089e8..2a6a1ee889d8a 100644
--- a/flang/test/Driver/fixed-line-length.f90
+++ b/flang/test/Driver/fixed-line-length.f90
@@ -6,6 +6,7 @@
 ! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/fixed-line-length-test.f  
2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH
 ! RUN: not %flang -E -Xflang -fno-reformat -ffixed-line-length=-2 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=NEGATIVELENGTH
 ! RUN: not %flang -E -Xflang -fno-reformat -ffixed-line-length=3 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
+! RUN: not %flang -E -Xflang -fno-reformat -ffixed-line-length=4294967296 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=OVERFLOWLENGTH
 ! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length=none 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length=0 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length=13 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
@@ -16,6 +17,7 @@
 ! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/fixed-line-length-test.f  2>&1 | 
FileCheck %s --check-prefix=DEFAULTLENGTH
 ! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=-2 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=NEGATIVELENGTH
 ! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=3 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
+! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=4294967296 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=OVERFLOWLENGTH
 ! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length=none 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length=0 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length=13 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
@@ -33,6 +35,8 @@
 
 ! INVALIDLENGTH: invalid value '3' in 'ffixed-line-length=', value must be '7' 
or greater
 
+! OVERFLOWLENGTH: invalid value '4294967296' in 'ffixed-line-length=', value 
must be '2147483647' or smaller
+
 ! The line should not be trimmed and so 73 characters (including spaces) 
should be read.
 ! UNLIMITEDLENGTH: program{{(a{59})}}
 

>From 760d52cadaea670773bfa375160e5cffde0081dc Mon Sep 17 00:00:00 2001
From: popie52 <[email protected]>
Date: Sun, 11 Oct 2026 11:02:22 +0530
Subject: [PATCH 2/2] [flang] Test fixed line length integer boundary

---
 flang/test/Driver/fixed-line-length.f90 | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/flang/test/Driver/fixed-line-length.f90 
b/flang/test/Driver/fixed-line-length.f90
index 2a6a1ee889d8a..06d184d5e0109 100644
--- a/flang/test/Driver/fixed-line-length.f90
+++ b/flang/test/Driver/fixed-line-length.f90
@@ -7,6 +7,7 @@
 ! RUN: not %flang -E -Xflang -fno-reformat -ffixed-line-length=-2 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=NEGATIVELENGTH
 ! RUN: not %flang -E -Xflang -fno-reformat -ffixed-line-length=3 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
 ! RUN: not %flang -E -Xflang -fno-reformat -ffixed-line-length=4294967296 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=OVERFLOWLENGTH
+! RUN: not %flang -E -Xflang -fno-reformat -ffixed-line-length=2147483648 
%S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=BOUNDARY
 ! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length=none 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length=0 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length=13 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
@@ -18,9 +19,11 @@
 ! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=-2 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=NEGATIVELENGTH
 ! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=3 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=INVALIDLENGTH
 ! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=4294967296 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=OVERFLOWLENGTH
+! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=2147483648 
%S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=BOUNDARY
 ! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length=none 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length=0 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 ! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length=13 
%S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
+! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length=2147483647 
%S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s 
--check-prefix=UNLIMITEDLENGTH
 
 !-------------------------------------
 ! COMMAND ALIAS -ffixed-line-length-n
@@ -31,6 +34,8 @@
 ! The line should be trimmed to 72 characters when reading based on the 
default value of fixed line length.
 ! DEFAULTLENGTH: program{{(a{58})}}
 
+! BOUNDARY: invalid value '2147483648' in 'ffixed-line-length=', value must be 
'2147483647' or smaller
+
 ! NEGATIVELENGTH: invalid value '-2' in 'ffixed-line-length=', value must be 
'none' or a positive integer
 
 ! INVALIDLENGTH: invalid value '3' in 'ffixed-line-length=', value must be '7' 
or greater

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

Reply via email to