[flang-commits] [clang] [flang] [Flang] Adding -ffree-line-length-<value> flag (PR #192941)
Jean-Didier PAILLEUX via flang-commits
flang-commits at lists.llvm.org
Wed Apr 29 12:47:27 PDT 2026
================
@@ -808,27 +808,34 @@ 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)) {
+ 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;
} else if (argValue.getAsInteger(/*Radix=*/10, columns)) {
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) {
- opts.fixedFormColumns = 1000000;
- } else if (columns < 7) {
+ columns = 10000;
+ } else if (columns < 7 && isFixedLineFlag) {
+ // Specific to the fixed form
diags.Report(clang::diag::err_drv_small_columns)
<< arg->getOption().getName() << arg->getValue() << "7";
- } else {
- opts.fixedFormColumns = columns;
}
+ if (isFixedLineFlag)
+ opts.fixedFormColumns = columns;
+ else
+ opts.freeFormColumns = columns;
----------------
JDPailleux wrote:
> What happens if someone calls flang -ffixed-line-length=72 -ffree-line-length=500 fixed-file.f free-file.f90 ?
It seems that it only takes the last one into account when I test it. And if `-ffree-line-length` is the last one, only free-file.f90 is affected, and the reverse for fixed-file
https://github.com/llvm/llvm-project/pull/192941
More information about the flang-commits
mailing list