[flang-commits] [flang] [flang] Fix fixed line length overflow diagnostic (PR #233353)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Mon Oct 19 11:50:28 PDT 2026


================
@@ -870,7 +870,15 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
     if (argValue == "none") {
       columns = 0;
     } else if (argValue.getAsInteger(/*Radix=*/10, columns)) {
-      columns = -1;
+      if (!argValue.empty() &&
+          std::all_of(argValue.begin(), argValue.end(),
+                      [](char c) { return c >= '0' && c <= '9'; })) {
+        // Route oversized positive decimals to the large-columns diagnostic.
+        columns =
+            static_cast<std::int64_t>(std::numeric_limits<int>::max()) + 1;
----------------
eugeneepshteyn wrote:

Optional: `INT_MAX + 1` is only there so the `> INT_MAX` check below fires, so it has to change if that bound ever does. Saturating to `std::numeric_limits<std::int64_t>::max()` says what the value actually is (too large for `int64_t`) and doesn't depend on the bound. `llvm::all_of(argValue, llvm::isDigit)` is also a shorter way to write the check.

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


More information about the flang-commits mailing list