llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-driver

@llvm/pr-subscribers-clang-driver

Author: Eugene Epshteyn (eugeneepshteyn)

<details>
<summary>Changes</summary>

Reverts llvm/llvm-project#<!-- -->192941 due to various important apps failures.

---
Full diff: https://github.com/llvm/llvm-project/pull/199018.diff


10 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (+1-1) 
- (modified) clang/include/clang/Options/FlangOptions.td (+1-5) 
- (modified) clang/lib/Driver/ToolChains/Flang.cpp (-1) 
- (modified) flang/include/flang/Frontend/FrontendOptions.h (+2-8) 
- (modified) flang/include/flang/Parser/options.h (-1) 
- (modified) flang/lib/Frontend/CompilerInvocation.cpp (+9-16) 
- (modified) flang/lib/Parser/parsing.cpp (-1) 
- (modified) flang/lib/Parser/prescan.cpp (-4) 
- (modified) flang/lib/Parser/prescan.h (-5) 
- (removed) flang/test/Driver/ffree-line-length.f90 (-48) 


``````````diff
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 10238eee2a49c..020014dabacfd 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_invalid_columns : Error<
+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">;
diff --git a/clang/include/clang/Options/FlangOptions.td 
b/clang/include/clang/Options/FlangOptions.td
index 7c9c3e97414c8..4fa0d7a9abcc6 100644
--- a/clang/include/clang/Options/FlangOptions.td
+++ b/clang/include/clang/Options/FlangOptions.td
@@ -22,6 +22,7 @@ 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>;
@@ -147,11 +148,6 @@ 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 the maximum line width in free-form mode">,
-  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>,
   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 61423425f4dcd..4c722a2e021eb 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -40,7 +40,6 @@ 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 409a88a7e50e4..0bd2e621813ca 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,
 
-  /// -ffixed-form
+  /// -ffree-form
   FixedForm,
 
-  /// -ffree-form
+  /// -ffixed-form
   FreeForm
 };
 
@@ -286,12 +286,6 @@ struct FrontendOptions {
   // source file.
   int fixedFormColumns = 72;
 
-  // The column after which characters are ignored in free form lines in the
-  // source file.
-  // 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
   /// file name.
   InputKind dashX;
diff --git a/flang/include/flang/Parser/options.h 
b/flang/include/flang/Parser/options.h
index adb01ae72639f..e65f253748d26 100644
--- a/flang/include/flang/Parser/options.h
+++ b/flang/include/flang/Parser/options.h
@@ -25,7 +25,6 @@ struct Options {
 
   bool isFixedForm{false};
   int fixedFormColumns{72};
-  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 9e868d8d8a0f1..9853fc600ff6a 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -807,15 +807,10 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
                            : FortranForm::FreeForm;
   }
 
-  // Set fixedFormColumns based on -ffixed-line-length=<value> or
-  // set freeFormColumns based on -ffree-line-length=<value>.
-  for (const auto *arg :
-       args.filtered(clang::options::OPT_ffixed_line_length_EQ,
-                     clang::options::OPT_ffree_line_length_EQ)) {
-
+  // Set fixedFormColumns based on -ffixed-line-length=<value>
+  if (const auto *arg =
+          args.getLastArg(clang::options::OPT_ffixed_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,17 +818,16 @@ static bool parseFrontendArgs(FrontendOptions &opts, 
llvm::opt::ArgList &args,
       columns = -1;
     }
     if (columns < 0) {
-      diags.Report(clang::diag::err_drv_invalid_columns)
+      diags.Report(clang::diag::err_drv_negative_columns)
           << arg->getOption().getName() << arg->getValue();
-    } else if (columns == 0 && isFixedLineFlag) {
-      columns = 1000000;
-    } else if (columns < 7 && isFixedLineFlag) {
-      // Specific to the fixed form
+    } else if (columns == 0) {
+      opts.fixedFormColumns = 1000000;
+    } else if (columns < 7) {
       diags.Report(clang::diag::err_drv_small_columns)
           << arg->getOption().getName() << arg->getValue() << "7";
+    } else {
+      opts.fixedFormColumns = columns;
     }
-
-    (isFixedLineFlag ? opts.fixedFormColumns : opts.freeFormColumns) = columns;
   }
 
   // Set conversion based on -fconvert=<value>
@@ -1896,7 +1890,6 @@ 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 3bdbcb3fd1281..667d8d9297ecb 100644
--- a/flang/lib/Parser/parsing.cpp
+++ b/flang/lib/Parser/parsing.cpp
@@ -75,7 +75,6 @@ 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 45e9806eee6bf..c1dd17400012a 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -42,7 +42,6 @@ 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_},
@@ -569,9 +568,6 @@ 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_ && (freeFormColumnLimit_ != 0) &&
-      column_ > freeFormColumnLimit_) {
-    return true;
   } 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 519ff01041ba5..8f4f390d4ea37 100644
--- a/flang/lib/Parser/prescan.h
+++ b/flang/lib/Parser/prescan.h
@@ -68,10 +68,6 @@ class Prescanner {
     fixedFormColumnLimit_ = limit;
     return *this;
   }
-  Prescanner &set_freeFormColumnLimit(int limit) {
-    freeFormColumnLimit_ = limit;
-    return *this;
-  }
 
   Prescanner &AddCompilerDirectiveSentinel(const std::string &);
 
@@ -273,7 +269,6 @@ class Prescanner {
   bool backslashFreeFormContinuation_{false};
   bool inFixedForm_{false};
   int fixedFormColumnLimit_{72};
-  int freeFormColumnLimit_{10000};
   Encoding encoding_{Encoding::UTF_8};
   int parenthesisNesting_{0};
   int prescannerNesting_{0};
diff --git a/flang/test/Driver/ffree-line-length.f90 
b/flang/test/Driver/ffree-line-length.f90
deleted file mode 100644
index 4168349e48496..0000000000000
--- a/flang/test/Driver/ffree-line-length.f90
+++ /dev/null
@@ -1,48 +0,0 @@
-! Ensure argument -ffree-line-length=n works as expected.
-
-!--------------------------
-! FLANG DRIVER (flang)
-!--------------------------
-! 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  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  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.
-! LENGTH35: program arbitrary_program_test_name
-
-! LENGTH13: program arbit

``````````

</details>


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

Reply via email to