https://github.com/macurtis-amd updated https://github.com/llvm/llvm-project/pull/117563
>From d8aed2a68c4a4330f77e8e62c920b033463f91cc Mon Sep 17 00:00:00 2001 From: Matthew Curtis <macur...@amd.com> Date: Mon, 2 Dec 2024 07:16:28 -0600 Subject: [PATCH] [flang] Treat pre-processed input as fixed --- clang/lib/Driver/ToolChains/Flang.cpp | 7 +++++++ flang/test/Driver/pp-fixed-form.f90 | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 flang/test/Driver/pp-fixed-form.f90 diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 8c18c88fbde7f7..72c0787d7df993 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -777,6 +777,13 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA, addFortranDialectOptions(Args, CmdArgs); + // 'flang -E' always produces output that is suitable for use as fixed form + // Fortran. However it is only valid free form source if the original is also + // free form. + if (InputType == types::TY_PP_Fortran && + !Args.getLastArg(options::OPT_ffixed_form, options::OPT_ffree_form)) + CmdArgs.push_back("-ffixed-form"); + handleColorDiagnosticsArgs(D, Args, CmdArgs); // LTO mode is parsed by the Clang driver library. diff --git a/flang/test/Driver/pp-fixed-form.f90 b/flang/test/Driver/pp-fixed-form.f90 new file mode 100644 index 00000000000000..4695da78763ae5 --- /dev/null +++ b/flang/test/Driver/pp-fixed-form.f90 @@ -0,0 +1,19 @@ +!RUN: %flang -save-temps -### %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FREE +FREE: "-fc1" {{.*}} "-o" "free-form-test.i" {{.*}} "-x" "f95-cpp-input" "{{.*}}/free-form-test.f90" +FREE-NEXT: "-fc1" {{.*}} "-ffixed-form" {{.*}} "-x" "f95" "free-form-test.i" + +!RUN: %flang -save-temps -### %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=FIXED +FIXED: "-fc1" {{.*}} "-o" "fixed-form-test.i" {{.*}} "-x" "f95-cpp-input" "{{.*}}/fixed-form-test.f" +FIXED-NEXT: "-fc1" {{.*}} "-ffixed-form" {{.*}} "-x" "f95" "fixed-form-test.i" + +!RUN: %flang -save-temps -### -ffree-form %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FREE-FLAG +FREE-FLAG: "-fc1" {{.*}} "-o" "free-form-test.i" {{.*}} "-x" "f95-cpp-input" "{{.*}}/free-form-test.f90" +FREE-FLAG-NEXT: "-fc1" {{.*}} "-emit-llvm-bc" "-ffree-form" +FREE-FLAG-NOT: "-ffixed-form" +FREE-FLAG-SAME: "-x" "f95" "free-form-test.i" + +!RUN: %flang -save-temps -### -ffixed-form %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=FIXED-FLAG +FIXED-FLAG: "-fc1" {{.*}} "-o" "fixed-form-test.i" {{.*}} "-x" "f95-cpp-input" "{{.*}}/fixed-form-test.f" +FIXED-FLAG-NEXT: "-fc1" {{.*}} "-emit-llvm-bc" "-ffixed-form" +FIXED-FLAG-NOT: "-ffixed-form" +FIXED-FLAG-SAME: "-x" "f95" "fixed-form-test.i" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits