[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 11:13:03 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>


================
@@ -863,6 +863,12 @@ static void parsePreprocessorArgs(Fortran::frontend::PreprocessorOptions &opts,
         (currentArg->getOption().matches(clang::driver::options::OPT_cpp))
             ? PPMacrosFlag::Include
             : PPMacrosFlag::Exclude;
+  // Enable -cpp based on -x unless explicitly disabled with -nocpp
+  if (opts.macrosFlag != PPMacrosFlag::Exclude)
+    if (const auto *dashX = args.getLastArg(clang::driver::options::OPT_x))
+      opts.macrosFlag = llvm::StringSwitch<PPMacrosFlag>(dashX->getValue())
+                            .Case("f95-cpp-input", PPMacrosFlag::Include)
----------------
DavidTruby wrote:

I believe we concluded that `f95-cpp-input` should mean that it has _already_ been preprocessed, and so does not need preprocessing again, and fixed that elsewhere. So this should be `PPMacrosFlag::Exclude` since `-x f95-cpp-input` is what we pass for `.f90` files, and that's where the issue is coming from.

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


More information about the cfe-commits mailing list