[clang] [flang] [flang] Align `-x` language modes with `gfortran` (PR #130268)

David Truby via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 31 10:59:13 PDT 2025


=?utf-8?q?IƱaki?= Amatria Barral <inaki.amatria at appentra.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/130268 at github.com>


================
@@ -817,8 +817,13 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
 
   // '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 &&
+  // free form. Ensure this logic does not incorrectly assume fixed-form for
+  // cases where it shouldn't, such as `flang -x f95 foo.f90`.
+  bool isAtemporaryPreprocessedFile =
+      Input.isFilename() &&
+      llvm::sys::path::extension(Input.getFilename())
+          .ends_with(types::getTypeTempSuffix(InputType, /*CLStyle=*/false));
+  if (InputType == types::TY_PP_Fortran && isAtemporaryPreprocessedFile &&
----------------
DavidTruby wrote:

I've only just spotted this, but this requirement that `isAtemporaryPreprocessedFile` appears to have changed the default for _all_ files to `-cpp` instead of `-nocpp`. I don't think this patch intended that change?

https://github.com/llvm/llvm-project/pull/130268


More information about the cfe-commits mailing list