Author: macurtis-amd Date: 2024-12-03T06:59:57-06:00 New Revision: 81d82cac8c4cbd006bf991fd7380de2d72858d1c
URL: https://github.com/llvm/llvm-project/commit/81d82cac8c4cbd006bf991fd7380de2d72858d1c DIFF: https://github.com/llvm/llvm-project/commit/81d82cac8c4cbd006bf991fd7380de2d72858d1c.diff LOG: [flang] Treat pre-processed input as fixed (#117563) Fixes an issue introduced by 9fb2db1e1f42 [flang] Retain spaces when preprocessing fixed-form source Where flang -fc1 fails to parse preprocessor output because it now remains in fixed form. Added: flang/test/Driver/pp-fixed-form.f90 Modified: clang/lib/Driver/ToolChains/Flang.cpp Removed: ################################################################################ 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