[all-commits] [llvm/llvm-project] 443d69: [flang][driver] Add support for fixed form detection

Faris via All-commits all-commits at lists.llvm.org
Tue Jan 19 05:00:46 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 443d6957ca712aacdfd72c3408a8837580f6a286
      https://github.com/llvm/llvm-project/commit/443d6957ca712aacdfd72c3408a8837580f6a286
  Author: Faris Rehman <faris.rehman at arm.com>
  Date:   2021-01-19 (Tue, 19 Jan 2021)

  Changed paths:
    M flang/include/flang/FrontendTool/Utils.h
    M flang/lib/Frontend/FrontendAction.cpp
    M flang/lib/Frontend/FrontendOptions.cpp
    M flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
    A flang/test/Flang-Driver/Inputs/fixed-form-test.f
    A flang/test/Flang-Driver/Inputs/free-form-test.f90
    A flang/test/Flang-Driver/fixed-free-detection.f90
    M flang/test/lit.cfg.py
    M flang/unittests/Frontend/FrontendActionTest.cpp

  Log Message:
  -----------
  [flang][driver] Add support for fixed form detection

Currently the new flang driver always runs in free form mode. This patch
adds support for fixed form mode detection based on the file extensions.

Like `f18`, `flang-new` will treat files ending with ".f", ".F" and
".ff" as fixed form. Additionally, ".for", ".FOR", ".fpp" and ".FPP"
file extensions are recognised as fixed form files. This is consistent
with gfortran [1]. In summary, files with the following extensions are
treated as fixed-form:
  * ".f", ".F", ".ff", ".for", ".FOR", ".fpp", ".FPP"

For consistency with flang/test/lit.cfg.py and f18, this patch also adds
support for the following file extensions:
  * ".ff", ".FOR", ".for", ".ff90", ".fpp", ".FPP"
This is added in flang/lib/Frontend/FrontendOptions.cpp. Additionally,
the following extensions are included:
  * ".f03", ".F03", ".f08", ".F08"
This is for compatibility with gfortran [1] and other popular Fortran
compilers [2].

NOTE: internally Flang will only differentiate between fixed and free
form files. Currently Flang does not support switching between language
standards, so in this regard file extensions are irrelevant. More
specifically, both `file.f03` and `file.f18` are represented with
`Language::Fortran` (as opposed to e.g. `Language::Fortran03`).

Summary of changes:
- Set Fortran::parser::Options::sFixedForm according to the file type
- Add isFixedFormSuffix and isFreeFormSuffix helper functions to
  FrontendTool/Utils.h
- Change FrontendOptions::GetInputKindForExtension to support the missing
  file extensions that f18 supports and some additional ones
- FrontendActionTest.cpp is updated to make sure that the test input is
  treated as free-form

[1] https://gcc.gnu.org/onlinedocs/gfortran/GNU-Fortran-and-GCC.html
[2] https://github.com/llvm/llvm-project/blob/master/flang/docs/OptionComparison.md#notes

Differential Revision: https://reviews.llvm.org/D94228




More information about the All-commits mailing list