diff options
author | Peter Klausler <pklausler@nvidia.com> | 2024-09-30 12:38:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-30 12:38:47 -0700 |
commit | 4dfed691a9f846b1ff773e28b878404b78559890 (patch) | |
tree | b024b0dec81535ab81aa180815d9edf98f4bf0c4 /flang/lib/Frontend | |
parent | 9b3818ecae5a5c47eb6a8dd44cf7e1c3666a0f02 (diff) | |
download | llvm-4dfed691a9f846b1ff773e28b878404b78559890.zip llvm-4dfed691a9f846b1ff773e28b878404b78559890.tar.gz llvm-4dfed691a9f846b1ff773e28b878404b78559890.tar.bz2 |
[flang][preprocessor] Don't expand INCLUDE under -E by default (#110333)
Fortran INCLUDE lines have (until now) been treated like #include
directives. This isn't how things work with other Fortran compilers when
running under the -E option for preprocessing only, so stop doing it by
default, and add -fpreprocess-include-lines to turn it back on when
desired.
Diffstat (limited to 'flang/lib/Frontend')
-rw-r--r-- | flang/lib/Frontend/CompilerInvocation.cpp | 6 | ||||
-rw-r--r-- | flang/lib/Frontend/FrontendAction.cpp | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index d68534d..2154b9a 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -820,6 +820,8 @@ static void parsePreprocessorArgs(Fortran::frontend::PreprocessorOptions &opts, : PPMacrosFlag::Exclude; opts.noReformat = args.hasArg(clang::driver::options::OPT_fno_reformat); + opts.preprocessIncludeLines = + args.hasArg(clang::driver::options::OPT_fpreprocess_include_lines); opts.noLineDirectives = args.hasArg(clang::driver::options::OPT_P); opts.showMacros = args.hasArg(clang::driver::options::OPT_dM); } @@ -1486,6 +1488,10 @@ void CompilerInvocation::setFortranOpts() { } fortranOptions.fixedFormColumns = frontendOptions.fixedFormColumns; + // -E + fortranOptions.prescanAndReformat = + frontendOptions.programAction == PrintPreprocessedInput; + fortranOptions.features = frontendOptions.features; fortranOptions.encoding = frontendOptions.encoding; diff --git a/flang/lib/Frontend/FrontendAction.cpp b/flang/lib/Frontend/FrontendAction.cpp index 42a614f..041182b 100644 --- a/flang/lib/Frontend/FrontendAction.cpp +++ b/flang/lib/Frontend/FrontendAction.cpp @@ -95,6 +95,10 @@ bool FrontendAction::beginSourceFile(CompilerInstance &ci, getCurrentInput().getIsCUDAFortran()); } + // -fpreprocess-include-lines + invoc.getFortranOpts().expandIncludeLinesInPreprocessedOutput = + invoc.getPreprocessorOpts().preprocessIncludeLines; + // Decide between fixed and free form (if the user didn't express any // preference, use the file extension to decide) if (invoc.getFrontendOpts().fortranForm == FortranForm::Unknown) { |