[flang-commits] [flang] [flang] Accept C-style comments in label fields (PR #207012)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Fri Sep 18 12:06:41 PDT 2026
================
@@ -83,13 +83,21 @@ bool FrontendAction::beginSourceFile(CompilerInstance &ci,
// * `-cpp/-nocpp`, or
// * the file extension (if the user didn't express any preference)
// to decide whether to include them or not.
- if ((invoc.getPreprocessorOpts().macrosFlag == PPMacrosFlag::Include) ||
+ bool includeMacros =
+ (invoc.getPreprocessorOpts().macrosFlag == PPMacrosFlag::Include) ||
(invoc.getPreprocessorOpts().showMacros) ||
(invoc.getPreprocessorOpts().macrosFlag == PPMacrosFlag::Unknown &&
- getCurrentInput().getMustBePreprocessed())) {
+ getCurrentInput().getMustBePreprocessed());
+ if (includeMacros) {
invoc.setDefaultPredefinitions();
invoc.collectMacroDefinitions();
}
+ // Preprocessing is enabled if macros are included or if `-E` is specified
+ // and `-nocpp` is not.
+ invoc.getFortranOpts().preprocessingEnabled =
----------------
luporl wrote:
It seemed to me that `-E` should imply `preprocessingEnabled`, but I had not considered the `-save-temps` pipeline. To avoid introducing asymmetries or adding complexity to the frontend I reverted that change.
For reference, this is the behavior of other compilers:
- gfortran -E: `error: gfortran does not support -E without -cpp`
- ifx -E: always accepts C-style comments, independent of the `-fpp` and `-nofpp` flags.
https://github.com/llvm/llvm-project/pull/207012
More information about the flang-commits
mailing list