aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorIƱaki Amatria Barral <140811900+inaki-amatria@users.noreply.github.com>2025-03-12 16:45:33 +0100
committerGitHub <noreply@github.com>2025-03-12 16:45:33 +0100
commitbdbe8fa1f3dcde77f7e0741ea7fa757ce092a420 (patch)
tree29d2a6638c535315896fb0b5d5e9d4ff5e5eaeca /flang/lib/Frontend/CompilerInvocation.cpp
parent1db978cd781314a15277ea23a11ebd58604685d7 (diff)
downloadllvm-bdbe8fa1f3dcde77f7e0741ea7fa757ce092a420.zip
llvm-bdbe8fa1f3dcde77f7e0741ea7fa757ce092a420.tar.gz
llvm-bdbe8fa1f3dcde77f7e0741ea7fa757ce092a420.tar.bz2
[flang] Align `-x` language modes with `gfortran` (#130268)
This PR addresses some of the issues described in https://github.com/llvm/llvm-project/issues/127617. Key changes: - Stop assuming fixed-form for `-x f95` unless the input is a `.i` file. This change ensures compatibility with `-save-temps` workflows while preventing unintended fixed-form assumptions. - Ensure `-x f95-cpp-input` enables `-cpp` by default, aligning Flang's behavior with `gfortran`.
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 8b07a50..1537122 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -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)
+ .Default(opts.macrosFlag);
opts.noReformat = args.hasArg(clang::driver::options::OPT_fno_reformat);
opts.preprocessIncludeLines =