diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -701,7 +701,7 @@ def O : Joined<["-"], "O">, Group, Flags<[CC1Option]>; def O_flag : Flag<["-"], "O">, Flags<[CC1Option]>, Alias, AliasArgs<["1"]>; def Ofast : Joined<["-"], "Ofast">, Group, Flags<[CC1Option]>; -def P : Flag<["-"], "P">, Flags<[CC1Option]>, Group, +def P : Flag<["-"], "P">, Flags<[CC1Option,FlangOption,FC1Option]>, Group, HelpText<"Disable linemarker output in -E mode">, MarshallingInfoNegativeFlag>; def Qy : Flag<["-"], "Qy">, Flags<[CC1Option]>, @@ -4570,7 +4570,7 @@ HelpText<"Measure the parse tree">; def fdebug_pre_fir_tree : Flag<["-"], "fdebug-pre-fir-tree">, Group, HelpText<"Dump the pre-FIR tree">; -def fdebug_module_writer : Flag<["-"],"fdebug-module-writer">, +def fdebug_module_writer : Flag<["-"],"fdebug-module-writer">, HelpText<"Enable debug messages while writing module files">; def fget_symbols_sources : Flag<["-"], "fget-symbols-sources">, Group, HelpText<"Dump symbols and their source code locations">; @@ -4582,7 +4582,8 @@ def fno_analyzed_objects_for_unparse : Flag<["-"], "fno-analyzed-objects-for-unparse">, Group, HelpText<"Do not use the analyzed objects when unparsing">; - +def fno_reformat : Flag<["-"], "fno-reformat">, Group, + HelpText<"Dump the cooked character stream in -E mode">; } //===----------------------------------------------------------------------===// diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -37,8 +37,9 @@ void Flang::AddPreprocessingOptions(const ArgList &Args, ArgStringList &CmdArgs) const { - Args.AddAllArgs(CmdArgs, {options::OPT_D, options::OPT_U, options::OPT_I, - options::OPT_cpp, options::OPT_nocpp}); + Args.AddAllArgs(CmdArgs, + {options::OPT_P, options::OPT_D, options::OPT_U, + options::OPT_I, options::OPT_cpp, options::OPT_nocpp}); } void Flang::AddOtherOptions(const ArgList &Args, ArgStringList &CmdArgs) const { diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h --- a/flang/include/flang/Frontend/FrontendOptions.h +++ b/flang/include/flang/Frontend/FrontendOptions.h @@ -25,7 +25,7 @@ /// -test-io mode InputOutputTest, - /// -E mode. + /// -E mode PrintPreprocessedInput, /// -fsyntax-only diff --git a/flang/include/flang/Frontend/PreprocessorOptions.h b/flang/include/flang/Frontend/PreprocessorOptions.h --- a/flang/include/flang/Frontend/PreprocessorOptions.h +++ b/flang/include/flang/Frontend/PreprocessorOptions.h @@ -44,6 +44,12 @@ PPMacrosFlag macrosFlag_ = PPMacrosFlag::Unknown; + // -P: Suppress #line directives in -E output + bool noLineDirectives{false}; + + // -fno-reformat: Emit cooked character stream as -E output + bool noReformat{false}; + public: PreprocessorOptions() {} diff --git a/flang/include/flang/Parser/parsing.h b/flang/include/flang/Parser/parsing.h --- a/flang/include/flang/Parser/parsing.h +++ b/flang/include/flang/Parser/parsing.h @@ -37,6 +37,7 @@ bool isModuleFile{false}; bool needProvenanceRangeToCharBlockMappings{false}; Fortran::parser::Encoding encoding{Fortran::parser::Encoding::UTF_8}; + bool prescanAndReformat{false}; // -E }; class Parsing { @@ -47,12 +48,15 @@ bool consumedWholeFile() const { return consumedWholeFile_; } const char *finalRestingPlace() const { return finalRestingPlace_; } AllCookedSources &allCooked() { return allCooked_; } + const AllCookedSources &allCooked() const { return allCooked_; } Messages &messages() { return messages_; } std::optional &parseTree() { return parseTree_; } const CookedSource &cooked() const { return DEREF(currentCooked_); } const SourceFile *Prescan(const std::string &path, Options); + void EmitPreprocessedSource( + llvm::raw_ostream &, bool lineDirectives = true) const; void DumpCookedChars(llvm::raw_ostream &) const; void DumpProvenance(llvm::raw_ostream &) const; void DumpParsingLog(llvm::raw_ostream &) const; diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -371,6 +371,9 @@ (currentArg->getOption().matches(clang::driver::options::OPT_cpp)) ? PPMacrosFlag::Include : PPMacrosFlag::Exclude; + + opts.noReformat = args.hasArg(clang::driver::options::OPT_fno_reformat); + opts.noLineDirectives = args.hasArg(clang::driver::options::OPT_P); } /// Parses all semantic related arguments and populates the variables diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp --- a/flang/lib/Frontend/FrontendActions.cpp +++ b/flang/lib/Frontend/FrontendActions.cpp @@ -208,9 +208,14 @@ std::string buf; llvm::raw_string_ostream outForPP{buf}; - // Run the preprocessor + // Format or dump the prescanner's output CompilerInstance &ci = this->instance(); - ci.parsing().DumpCookedChars(outForPP); + if (ci.invocation().preprocessorOpts().noReformat) { + ci.parsing().DumpCookedChars(outForPP); + } else { + ci.parsing().EmitPreprocessedSource( + outForPP, !ci.invocation().preprocessorOpts().noLineDirectives); + } // If a pre-defined output stream exists, dump the preprocessed content there if (!ci.IsOutputStreamNull()) { @@ -219,7 +224,7 @@ return; } - // Print diagnostics from the preprocessor + // Print diagnostics from the prescanner ci.parsing().messages().Emit(llvm::errs(), ci.allCookedSources()); // Create a file and save the preprocessed output there @@ -228,7 +233,6 @@ (*os) << outForPP.str(); } else { llvm::errs() << "Unable to create the output file\n"; - return; } } diff --git a/flang/lib/Frontend/FrontendOptions.cpp b/flang/lib/Frontend/FrontendOptions.cpp --- a/flang/lib/Frontend/FrontendOptions.cpp +++ b/flang/lib/Frontend/FrontendOptions.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "flang/Frontend/FrontendOptions.h" -#include "flang/Evaluate/expression.h" using namespace Fortran::frontend; diff --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp --- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -28,61 +28,43 @@ switch (ak) { case InputOutputTest: return std::make_unique(); - break; case PrintPreprocessedInput: return std::make_unique(); - break; case ParseSyntaxOnly: return std::make_unique(); case EmitObj: return std::make_unique(); - break; case DebugUnparse: return std::make_unique(); - break; case DebugUnparseNoSema: return std::make_unique(); - break; case DebugUnparseWithSymbols: return std::make_unique(); - break; case DebugDumpSymbols: return std::make_unique(); - break; case DebugDumpParseTree: return std::make_unique(); - break; case DebugDumpParseTreeNoSema: return std::make_unique(); - break; case DebugDumpAll: return std::make_unique(); - break; case DebugDumpProvenance: return std::make_unique(); - break; case DebugDumpParsingLog: return std::make_unique(); - break; case DebugMeasureParseTree: return std::make_unique(); - break; case DebugPreFIRTree: return std::make_unique(); - break; case GetDefinition: return std::make_unique(); - break; case GetSymbolsSources: return std::make_unique(); - break; case InitOnly: return std::make_unique(); - break; default: break; // TODO: - // case RunPreprocessor: // case ParserSyntaxOnly: // case EmitLLVM: // case EmitLLVMOnly: diff --git a/flang/lib/Parser/parsing.cpp b/flang/lib/Parser/parsing.cpp --- a/flang/lib/Parser/parsing.cpp +++ b/flang/lib/Parser/parsing.cpp @@ -95,6 +95,94 @@ return sourceFile; } +void Parsing::EmitPreprocessedSource( + llvm::raw_ostream &out, bool lineDirectives) const { + const SourceFile *sourceFile{nullptr}; + int sourceLine{0}; + int column{1}; + bool inDirective{false}; + bool inContinuation{false}; + const AllSources &allSources{allCooked().allSources()}; + for (const char &atChar : cooked().AsCharBlock()) { + char ch{atChar}; + if (ch == '\n') { + out << '\n'; // TODO: DOS CR-LF line ending if necessary + column = 1; + inDirective = false; + inContinuation = false; + ++sourceLine; + } else { + if (ch == '!') { + // Other comment markers (C, *, D) in original fixed form source + // input card column 1 will have been deleted or normalized to !, + // which signifies a comment (directive) in both source forms. + inDirective = true; + } + auto provenance{cooked().GetProvenanceRange(CharBlock{&atChar, 1})}; + std::optional position{provenance + ? allSources.GetSourcePosition(provenance->start()) + : std::nullopt}; + if (lineDirectives && column == 1 && position) { + if (&position->file != sourceFile) { + out << "#line \"" << position->file.path() << "\" " << position->line + << '\n'; + } else if (position->line != sourceLine) { + if (sourceLine < position->line && + sourceLine + 10 >= position->line) { + // Emit a few newlines to catch up when they'll likely + // require fewer bytes than a #line directive would have + // occupied. + while (sourceLine++ < position->line) { + out << '\n'; + } + } else { + out << "#line " << position->line << '\n'; + } + } + sourceFile = &position->file; + sourceLine = position->line; + } + if (column > 72) { + // Wrap long lines in a portable fashion that works in both + // of the Fortran source forms. The first free-form continuation + // marker ("&") lands in column 73, which begins the card commentary + // field of fixed form, and the second one is put in column 6, + // where it signifies fixed form line continuation. + // The standard Fortran fixed form column limit (72) is used + // for output, even if the input was parsed with a nonstandard + // column limit override option. + out << "&\n &"; + column = 7; // start of fixed form source field + ++sourceLine; + inContinuation = true; + } else if (!inDirective && ch != ' ' && (ch < '0' || ch > '9')) { + // Put anything other than a label or directive into the + // Fortran fixed form source field (columns [7:72]). + for (; column < 7; ++column) { + out << ' '; + } + } + if (!inContinuation && position && position->column <= 72 && ch != ' ') { + // Preserve original indentation + for (; column < position->column; ++column) { + out << ' '; + } + } + if (ch >= 'a' && ch <= 'z' && provenance && provenance->size() == 1) { + // Preserve original case + if (const char *orig{allSources.GetSource(*provenance)}) { + auto upper{static_cast(ch + 'A' - 'a')}; + if (*orig == upper) { + ch = upper; + } + } + } + out << ch; + ++column; + } + } +} + void Parsing::DumpCookedChars(llvm::raw_ostream &out) const { UserState userState{allCooked_, common::LanguageFeatureControl{}}; ParseState parseState{cooked()}; diff --git a/flang/lib/Parser/provenance.cpp b/flang/lib/Parser/provenance.cpp --- a/flang/lib/Parser/provenance.cpp +++ b/flang/lib/Parser/provenance.cpp @@ -323,12 +323,20 @@ std::optional AllSources::GetSourcePosition( Provenance prov) const { const Origin &origin{MapToOrigin(prov)}; - if (const auto *inc{std::get_if(&origin.u)}) { - std::size_t offset{origin.covers.MemberOffset(prov)}; - return inc->source.FindOffsetLineAndColumn(offset); - } else { - return std::nullopt; - } + return std::visit( + common::visitors{ + [&](const Inclusion &inc) -> std::optional { + std::size_t offset{origin.covers.MemberOffset(prov)}; + return inc.source.FindOffsetLineAndColumn(offset); + }, + [&](const Macro &) { + return GetSourcePosition(origin.replaces.start()); + }, + [](const CompilerInsertion &) -> std::optional { + return std::nullopt; + }, + }, + origin.u); } std::optional AllSources::GetFirstFileProvenance() const { @@ -593,7 +601,7 @@ return result; } } - return nullptr; + return std::nullopt; } void AllCookedSources::Dump(llvm::raw_ostream &o) const { diff --git a/flang/lib/Parser/token-sequence.h b/flang/lib/Parser/token-sequence.h --- a/flang/lib/Parser/token-sequence.h +++ b/flang/lib/Parser/token-sequence.h @@ -119,7 +119,7 @@ TokenSequence &ClipComment(bool skipFirst = false); const TokenSequence &CheckBadFortranCharacters(Messages &) const; void Emit(CookedSource &) const; - void Dump(llvm::raw_ostream &) const; + llvm::raw_ostream &Dump(llvm::raw_ostream &) const; private: std::size_t TokenBytes(std::size_t token) const { diff --git a/flang/lib/Parser/token-sequence.cpp b/flang/lib/Parser/token-sequence.cpp --- a/flang/lib/Parser/token-sequence.cpp +++ b/flang/lib/Parser/token-sequence.cpp @@ -276,13 +276,14 @@ cooked.PutProvenanceMappings(provenances_); } -void TokenSequence::Dump(llvm::raw_ostream &o) const { +llvm::raw_ostream &TokenSequence::Dump(llvm::raw_ostream &o) const { o << "TokenSequence has " << char_.size() << " chars; nextStart_ " << nextStart_ << '\n'; for (std::size_t j{0}; j < start_.size(); ++j) { o << '[' << j << "] @ " << start_[j] << " '" << TokenAt(j).ToString() << "'\n"; } + return o; } Provenance TokenSequence::GetTokenProvenance( diff --git a/flang/test/Driver/cpp-nocpp-command-line-macro.f90 b/flang/test/Driver/cpp-nocpp-command-line-macro.f90 --- a/flang/test/Driver/cpp-nocpp-command-line-macro.f90 +++ b/flang/test/Driver/cpp-nocpp-command-line-macro.f90 @@ -8,11 +8,11 @@ !----------------- ! EXPECTED OUTPUT !----------------- -! UNDEFINED:program b -! UNDEFINED-NOT:program a +! UNDEFINED:program B +! UNDEFINED-NOT:program A -! DEFINED:program a -! DEFINED-NOT:program b +! DEFINED:program A +! DEFINED-NOT:program B #ifdef X program X diff --git a/flang/test/Driver/driver-help-hidden.f90 b/flang/test/Driver/driver-help-hidden.f90 --- a/flang/test/Driver/driver-help-hidden.f90 +++ b/flang/test/Driver/driver-help-hidden.f90 @@ -50,6 +50,7 @@ ! CHECK-NEXT: -nocpp Disable predefined and command line preprocessor macros ! CHECK-NEXT: -o Write output to ! CHECK-NEXT: -pedantic Warn on language extensions +! CHECK-NEXT: -P Disable linemarker output in -E mode ! CHECK-NEXT: -std= Language standard to compile for ! CHECK-NEXT: -U Undefine macro ! CHECK-NEXT: --version Print version information diff --git a/flang/test/Driver/driver-help.f90 b/flang/test/Driver/driver-help.f90 --- a/flang/test/Driver/driver-help.f90 +++ b/flang/test/Driver/driver-help.f90 @@ -50,6 +50,7 @@ ! HELP-NEXT: -nocpp Disable predefined and command line preprocessor macros ! HELP-NEXT: -o Write output to ! HELP-NEXT: -pedantic Warn on language extensions +! HELP-NEXT: -P Disable linemarker output in -E mode ! HELP-NEXT: -std= Language standard to compile for ! HELP-NEXT: -U Undefine macro ! HELP-NEXT: --version Print version information @@ -103,6 +104,7 @@ ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations ! HELP-FC1-NEXT: -fno-analyzed-objects-for-unparse ! HELP-FC1-NEXT: Do not use the analyzed objects when unparsing +! HELP-FC1-NEXT: -fno-reformat Dump the cooked character stream in -E mode ! HELP-FC1-NEXT: -fopenacc Enable OpenACC ! HELP-FC1-NEXT: -fopenmp Parse OpenMP pragmas and generate parallel code. ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV. @@ -114,6 +116,7 @@ ! HELP-FC1-NEXT: -nocpp Disable predefined and command line preprocessor macros ! HELP-FC1-NEXT: -o Write output to ! HELP-FC1-NEXT: -pedantic Warn on language extensions +! HELP-FC1-NEXT: -P Disable linemarker output in -E mode ! HELP-FC1-NEXT: -std= Language standard to compile for ! HELP-FC1-NEXT: -test-io Run the InputOuputTest action. Use for development and testing only. ! HELP-FC1-NEXT: -U Undefine macro diff --git a/flang/test/Driver/escaped-backslash.f90 b/flang/test/Driver/escaped-backslash.f90 --- a/flang/test/Driver/escaped-backslash.f90 +++ b/flang/test/Driver/escaped-backslash.f90 @@ -17,14 +17,14 @@ !----------------------------------------- ! EXPECTED OUTPUT FOR ESCAPED BACKSLASHES !----------------------------------------- -! ESCAPED:program backslash +! ESCAPED:program Backslash ! ESCAPED-NEXT:New\\nline ! ESCAPED-NOT:New\nline !------------------------------------------- ! EXPECTED OUTPUT FOR UNESCAPED BACKSLASHES !------------------------------------------- -! UNESCAPED:program backslash +! UNESCAPED:program Backslash ! UNESCAPED-NEXT:New\nline ! UNESCAPED-NOT:New\\nline diff --git a/flang/test/Driver/fixed-free-detection.f90 b/flang/test/Driver/fixed-free-detection.f90 --- a/flang/test/Driver/fixed-free-detection.f90 +++ b/flang/test/Driver/fixed-free-detection.f90 @@ -1,20 +1,20 @@ ! Ensure the driver correctly switches between fixed and free form based on the file extension. -! This test exploits the fact that the preprocessor treats white-spaces differently for free +! This test exploits the fact that the prescanner treats whitespace differently for free ! and fixed form input files. !-------------------------- ! FLANG DRIVER (flang) !-------------------------- -! RUN: %flang -E %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FREEFORM -! RUN: %flang -E %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=FIXEDFORM -! RUN: %flang -E %S/Inputs/free-form-test.f90 %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=MULTIPLEFORMS +! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FREEFORM +! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=FIXEDFORM +! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/free-form-test.f90 %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=MULTIPLEFORMS !----------------------------------------- ! FRONTEND FLANG DRIVER (flang_fc1) !----------------------------------------- -! RUN: %flang_fc1 -E %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FREEFORM -! RUN: %flang_fc1 -E %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=FIXEDFORM -! RUN: %flang_fc1 -E %S/Inputs/free-form-test.f90 %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=MULTIPLEFORMS +! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FREEFORM +! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=FIXEDFORM +! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/free-form-test.f90 %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=MULTIPLEFORMS !------------------------------------- ! EXPECTED OUTPUT FOR A FREE FORM FILE diff --git a/flang/test/Driver/fixed-line-length.f90 b/flang/test/Driver/fixed-line-length.f90 --- a/flang/test/Driver/fixed-line-length.f90 +++ b/flang/test/Driver/fixed-line-length.f90 @@ -5,28 +5,28 @@ !-------------------------- ! FLANG DRIVER (flang) !-------------------------- -! RUN: %flang -E %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH -! RUN: not %flang -E -ffixed-line-length=-2 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=NEGATIVELENGTH -! RUN: not %flang -E -ffixed-line-length=3 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH -! RUN: %flang -E -ffixed-line-length=none %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH -! RUN: %flang -E -ffixed-line-length=0 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH -! RUN: %flang -E -ffixed-line-length=13 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=LENGTH13 +! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH +! RUN: not %flang -E -Xflang -fno-reformat -ffixed-line-length=-2 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=NEGATIVELENGTH +! RUN: not %flang -E -Xflang -fno-reformat -ffixed-line-length=3 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH +! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length=none %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH +! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length=0 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH +! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length=13 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=LENGTH13 !---------------------------------------- ! FRONTEND FLANG DRIVER (flang -fc1) !---------------------------------------- -! RUN: %flang_fc1 -E %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH -! RUN: not %flang_fc1 -E -ffixed-line-length=-2 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=NEGATIVELENGTH -! RUN: not %flang_fc1 -E -ffixed-line-length=3 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH -! RUN: %flang_fc1 -E -ffixed-line-length=none %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH -! RUN: %flang_fc1 -E -ffixed-line-length=0 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH -! RUN: %flang_fc1 -E -ffixed-line-length=13 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=LENGTH13 +! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH +! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=-2 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=NEGATIVELENGTH +! RUN: not %flang_fc1 -E -fno-reformat -ffixed-line-length=3 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH +! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length=none %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH +! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length=0 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH +! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length=13 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=LENGTH13 !------------------------------------- ! COMMAND ALIAS -ffixed-line-length-n !------------------------------------- -! RUN: %flang -E -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=LENGTH13 -! RUN: %flang_fc1 -E -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=LENGTH13 +! RUN: %flang -E -Xflang -fno-reformat -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=LENGTH13 +! RUN: %flang_fc1 -E -fno-reformat -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=LENGTH13 !------------------------------------- ! EXPECTED OUTPUT WITH DEFAULT LENGTH diff --git a/flang/test/Driver/frontend-forwarding.f90 b/flang/test/Driver/frontend-forwarding.f90 --- a/flang/test/Driver/frontend-forwarding.f90 +++ b/flang/test/Driver/frontend-forwarding.f90 @@ -9,8 +9,10 @@ ! RUN: -fdefault-integer-8 \ ! RUN: -fdefault-real-8 \ ! RUN: -flarge-sizes \ +! RUN: -P \ ! RUN: | FileCheck %s +! CHECK: "-P" ! CHECK: "-finput-charset=utf-8" ! CHECK: "-fdefault-double-8" ! CHECK: "-fdefault-integer-8" diff --git a/flang/test/Driver/include-header.f90 b/flang/test/Driver/include-header.f90 --- a/flang/test/Driver/include-header.f90 +++ b/flang/test/Driver/include-header.f90 @@ -26,35 +26,32 @@ !--------------------------------------------- ! EXPECTED OUTPUT FOR A SINGLE INCLUDED FOLDER !-------------------------------------------- -! SINGLEINCLUDE:program maindirectoryone -! SINGLEINCLUDE-NOT:program x -! SINGLEINCLUDE-NOT:program b -! SINGLEINCLUDE-NEXT:end -! SINGLEINCLUDE-NEXT:program maindirectorytwo -! SINGLEINCLUDE-NOT:program y -! SINGLEINCLUDE-NOT:program c +! SINGLEINCLUDE:program MainDirectoryOne +! SINGLEINCLUDE-NOT:program X +! SINGLEINCLUDE-NOT:program B +! SINGLEINCLUDE:program MainDirectoryTwo +! SINGLEINCLUDE-NOT:program Y +! SINGLEINCLUDE-NOT:program C !------------------------------------------------------- ! EXPECTED OUTPUT FOR Inputs/ DIRECTORY SPECIFIED FIRST !------------------------------------------------------- -! MAINDIRECTORY:program maindirectoryone -! MAINDIRECTORY-NOT:program subdirectoryone -! MAINDIRECTORY-NOT:program b -! MAINDIRECTORY-NEXT:end -! MAINDIRECTORY-NEXT:program maindirectorytwo -! MAINDIRECTORY-NOT:program subdirectorytwo -! MAINDIRECTORY-NOT:program c +! MAINDIRECTORY:program MainDirectoryOne +! MAINDIRECTORY-NOT:program SubDirectoryOne +! MAINDIRECTORY-NOT:program B +! MAINDIRECTORY:program MainDirectoryTwo +! MAINDIRECTORY-NOT:program SubDirectoryTwo +! MAINDIRECTORY-NOT:program C !------------------------------------------------------------------ ! EXPECTED OUTPUT FOR Inputs/header-dir/ DIRECTORY SPECIFIED FIRST !------------------------------------------------------------------ -! SUBDIRECTORY:program subdirectoryone -! SUBDIRECTORY-NOT:program maindirectoryone -! SUBDIRECTORY-NOT:program b -! SUBDIRECTORY-NEXT:end -! SUBDIRECTORY-NEXT:program subdirectorytwo -! SUBDIRECTORY-NOT:program maindirectorytwo -! SUBDIRECTORY-NOT:program c +! SUBDIRECTORY:program SubDirectoryOne +! SUBDIRECTORY-NOT:program MainDirectoryOne +! SUBDIRECTORY-NOT:program B +! SUBDIRECTORY:program SubDirectoryTwo +! SUBDIRECTORY-NOT:program MainDirectoryTwo +! SUBDIRECTORY-NOT:program C ! include-test-one.f90 #include diff --git a/flang/test/Driver/input-from-stdin.f90 b/flang/test/Driver/input-from-stdin.f90 --- a/flang/test/Driver/input-from-stdin.f90 +++ b/flang/test/Driver/input-from-stdin.f90 @@ -30,8 +30,8 @@ !------------------------- ! EXPECTED OUTPUT for `-E` !------------------------- -! PP-NOT-DEFINED: program b -! PP-DEFINED: program a +! PP-NOT-DEFINED: Program B +! PP-DEFINED: Program A !------------------------------- ! EXPECTED OUTPUT for `-test-io` diff --git a/flang/test/Driver/macro-def-undef.F90 b/flang/test/Driver/macro-def-undef.F90 --- a/flang/test/Driver/macro-def-undef.F90 +++ b/flang/test/Driver/macro-def-undef.F90 @@ -3,30 +3,28 @@ !-------------------------- ! FLANG DRIVER (flang-new) !-------------------------- -! RUN: %flang -E %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED -! RUN: %flang -E -DX=A %s 2>&1 | FileCheck %s --check-prefix=DEFINED -! RUN: %flang -E -DX=A -UX %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED +! RUN: %flang -E -P %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED +! RUN: %flang -E -P -DX=A %s 2>&1 | FileCheck %s --check-prefix=DEFINED +! RUN: %flang -E -P -DX=A -UX %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED !----------------------------------------- ! FRONTEND FLANG DRIVER (flang-new -fc1) !----------------------------------------- -! RUN: %flang_fc1 -E %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED -! RUN: %flang_fc1 -E -DX=A %s 2>&1 | FileCheck %s --check-prefix=DEFINED -! RUN: %flang_fc1 -E -DX -UX %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED +! RUN: %flang_fc1 -E -P %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED +! RUN: %flang_fc1 -E -P -DX=A %s 2>&1 | FileCheck %s --check-prefix=DEFINED +! RUN: %flang_fc1 -E -P -DX -UX %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED !-------------------------------------------- ! EXPECTED OUTPUT FOR AN UNDEFINED MACRO !-------------------------------------------- -! UNDEFINED:program b -! UNDEFINED-NOT:program x -! UNDEFINED-NEXT:end +! UNDEFINED:program B +! UNDEFINED-NOT:program X !-------------------------------------------- ! EXPECTED OUTPUT FOR MACRO 'X' DEFINED AS A !-------------------------------------------- -! DEFINED:program a -! DEFINED-NOT:program b -! DEFINED-NEXT:end +! DEFINED:program A +! DEFINED-NOT:program B #ifdef X program X diff --git a/flang/test/Driver/macro-multiline.F90 b/flang/test/Driver/macro-multiline.F90 --- a/flang/test/Driver/macro-multiline.F90 +++ b/flang/test/Driver/macro-multiline.F90 @@ -5,18 +5,18 @@ !-------------------------- ! FLANG DRIVER (flang) !-------------------------- -! RUN: printf -- "-DX=A\\\\\nTHIS_SHOULD_NOT_EXIST_IN_THE_OUTPUT\n" | xargs %flang -E %s 2>&1 | FileCheck --strict-whitespace --match-full-lines %s +! RUN: printf -- "-DX=A\\\\\nTHIS_SHOULD_NOT_EXIST_IN_THE_OUTPUT\n" | xargs %flang -E -P %s 2>&1 | FileCheck --strict-whitespace --match-full-lines %s !----------------------------------------- ! FRONTEND FLANG DRIVER (flang_fc1) !----------------------------------------- -! RUN: printf -- "-DX=A\\\\\nTHIS_SHOULD_NOT_EXIST_IN_THE_OUTPUT\n" | xargs %flang_fc1 -E %s 2>&1 | FileCheck --strict-whitespace --match-full-lines %s +! RUN: printf -- "-DX=A\\\\\nTHIS_SHOULD_NOT_EXIST_IN_THE_OUTPUT\n" | xargs %flang_fc1 -E -P %s 2>&1 | FileCheck --strict-whitespace --match-full-lines %s !------------------------------- ! EXPECTED OUTPUT FOR MACRO 'X' !------------------------------- -! CHECK:start a end +! CHECK: START A END ! CHECK-NOT:THIS_SHOULD_NOT_EXIST_IN_THE_OUTPUT ! CHECK-NOT:this_should_not_exist_in_the_output -START X END + START X END diff --git a/flang/test/Parser/badlabel.f b/flang/test/Parser/badlabel.f --- a/flang/test/Parser/badlabel.f +++ b/flang/test/Parser/badlabel.f @@ -1,4 +1,4 @@ -! RUN: %flang_fc1 -E %s 2>&1 | FileCheck %s +! RUN: %flang_fc1 -E -fno-reformat %s 2>&1 | FileCheck %s ! CHECK: Label digit is not in fixed-form label field 1 continue ! CHECK: Label digit is not in fixed-form label field diff --git a/flang/test/Preprocessing/assert.F90 b/flang/test/Preprocessing/assert.F90 --- a/flang/test/Preprocessing/assert.F90 +++ b/flang/test/Preprocessing/assert.F90 @@ -1,4 +1,4 @@ -!RUN: %flang -E %s 2>&1 | FileCheck %s +!RUN: %flang -E -Xflang -fno-reformat %s 2>&1 | FileCheck %s !CHECK: if(.not.(.true.)) error stop "assert(" // ".TRUE." // ") failed " // "at "" !CHECK-SAME: assert.F90"": " // "7" #define STR(x) #x diff --git a/flang/test/Preprocessing/dash-E.F90 b/flang/test/Preprocessing/dash-E.F90 new file mode 100644 --- /dev/null +++ b/flang/test/Preprocessing/dash-E.F90 @@ -0,0 +1,25 @@ +! RUN: %flang -E %s 2>&1 | FileCheck --strict-whitespace %s +!CHECK: program Main +program Main +#define ADD(x,y) (x)+(y) +!CHECK: integer :: j = (1)+( 2) + integer :: j = ADD(1,& + 2) +!CHECK:1 format('This is a very long output literal edit descriptor for a F& +!CHECK: &ORMAT statement, and it will require statement continuation.') +1 format('This is a very long output literal edit descriptor for a FORMAT statement, and it will require statement continuation.') + + + + + + + + + + + + +!CHECK: #line 25 +!CHECK: end PROGRAM Main +end PROGRAM Main diff --git a/flang/test/Preprocessing/fixed-rescan.F b/flang/test/Preprocessing/fixed-rescan.F --- a/flang/test/Preprocessing/fixed-rescan.F +++ b/flang/test/Preprocessing/fixed-rescan.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s | FileCheck %s -! CHECK: callbar +! CHECK: call bar ! Ensure that rescanned lines after macro replacement are not ! misinterpreted as fixed-form comments when they start with C or D. #define foo bar diff --git a/flang/test/Preprocessing/hollerith.f b/flang/test/Preprocessing/hollerith.f --- a/flang/test/Preprocessing/hollerith.f +++ b/flang/test/Preprocessing/hollerith.f @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -Xflang -fno-reformat %s 2>&1 | FileCheck %s ! CHECK: character*1hi ! CHECK: dataa/1*1h / ! CHECK: datab/1*1h / diff --git a/flang/test/Preprocessing/pp001.F b/flang/test/Preprocessing/pp001.F --- a/flang/test/Preprocessing/pp001.F +++ b/flang/test/Preprocessing/pp001.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777.eq.777)then +! CHECK: if (777 .eq. 777) then * keyword macros integer, parameter :: KWM = 666 #define KWM 777 diff --git a/flang/test/Preprocessing/pp002.F b/flang/test/Preprocessing/pp002.F --- a/flang/test/Preprocessing/pp002.F +++ b/flang/test/Preprocessing/pp002.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(kwm.eq.777)then +! CHECK: if (KWM .eq. 777) then * #undef integer, parameter :: KWM = 777 #define KWM 666 diff --git a/flang/test/Preprocessing/pp003.F b/flang/test/Preprocessing/pp003.F --- a/flang/test/Preprocessing/pp003.F +++ b/flang/test/Preprocessing/pp003.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((666)+111) +! CHECK: res = ((666)+111) * function-like macros integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp004.F b/flang/test/Preprocessing/pp004.F --- a/flang/test/Preprocessing/pp004.F +++ b/flang/test/Preprocessing/pp004.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(kwm.eq.777)then +! CHECK: if (kwm .eq. 777) then * KWMs case-sensitive integer, parameter :: KWM = 777 #define KWM 666 diff --git a/flang/test/Preprocessing/pp005.F b/flang/test/Preprocessing/pp005.F --- a/flang/test/Preprocessing/pp005.F +++ b/flang/test/Preprocessing/pp005.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=777 +! CHECK: res = 777 * KWM split across continuation, implicit padding integer, parameter :: KWM = 666 #define KWM 777 diff --git a/flang/test/Preprocessing/pp006.F b/flang/test/Preprocessing/pp006.F --- a/flang/test/Preprocessing/pp006.F +++ b/flang/test/Preprocessing/pp006.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=777 +! CHECK: res = 777 * ditto, but with intervening *comment line integer, parameter :: KWM = 666 #define KWM 777 diff --git a/flang/test/Preprocessing/pp007.F b/flang/test/Preprocessing/pp007.F --- a/flang/test/Preprocessing/pp007.F +++ b/flang/test/Preprocessing/pp007.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=kwm +! CHECK: res = KWM * KWM split across continuation, clipped after column 72 integer, parameter :: KWM = 666 #define KWM 777 diff --git a/flang/test/Preprocessing/pp008.F b/flang/test/Preprocessing/pp008.F --- a/flang/test/Preprocessing/pp008.F +++ b/flang/test/Preprocessing/pp008.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=kwm +! CHECK: res = K W M * KWM with spaces in name at invocation NOT replaced integer, parameter :: KWM = 777 #define KWM 666 diff --git a/flang/test/Preprocessing/pp009.F b/flang/test/Preprocessing/pp009.F --- a/flang/test/Preprocessing/pp009.F +++ b/flang/test/Preprocessing/pp009.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((666)+111) +! CHECK: res = ((666)+111) * FLM call split across continuation, implicit padding integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp010.F b/flang/test/Preprocessing/pp010.F --- a/flang/test/Preprocessing/pp010.F +++ b/flang/test/Preprocessing/pp010.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((666)+111) +! CHECK: res = ((666)+111) * ditto, but with intervening *comment line integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp011.F b/flang/test/Preprocessing/pp011.F --- a/flang/test/Preprocessing/pp011.F +++ b/flang/test/Preprocessing/pp011.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=iflm(666) +! CHECK: res = IFLM(666) * FLM call name split across continuation, clipped integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp012.F b/flang/test/Preprocessing/pp012.F --- a/flang/test/Preprocessing/pp012.F +++ b/flang/test/Preprocessing/pp012.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((666)+111) +! CHECK: res = ((666)+111) * FLM call name split across continuation integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp013.F b/flang/test/Preprocessing/pp013.F --- a/flang/test/Preprocessing/pp013.F +++ b/flang/test/Preprocessing/pp013.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((666)+111) +! CHECK: res = ((666)+111) * FLM call split between name and ( integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp014.F b/flang/test/Preprocessing/pp014.F --- a/flang/test/Preprocessing/pp014.F +++ b/flang/test/Preprocessing/pp014.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((666)+111) +! CHECK: res = ((666)+111) * FLM call split between name and (, with intervening *comment integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp015.F b/flang/test/Preprocessing/pp015.F --- a/flang/test/Preprocessing/pp015.F +++ b/flang/test/Preprocessing/pp015.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((666)+111) +! CHECK: res = ((666)+111) * FLM call split between name and (, clipped integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp016.F b/flang/test/Preprocessing/pp016.F --- a/flang/test/Preprocessing/pp016.F +++ b/flang/test/Preprocessing/pp016.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((666)+111) +! CHECK: res = ((666)+111) * FLM call split between name and ( and in argument integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp017.F b/flang/test/Preprocessing/pp017.F --- a/flang/test/Preprocessing/pp017.F +++ b/flang/test/Preprocessing/pp017.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777.eq.777)then +! CHECK: if (777 .eq. 777) then * KLM rescan integer, parameter :: KWM = 666, KWM2 = 667 #define KWM2 777 diff --git a/flang/test/Preprocessing/pp018.F b/flang/test/Preprocessing/pp018.F --- a/flang/test/Preprocessing/pp018.F +++ b/flang/test/Preprocessing/pp018.F @@ -1,11 +1,11 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(kwm2.eq.777)then +! CHECK: if (KWM2 .eq. 777) then * KLM rescan with #undef (so rescan is after expansion) integer, parameter :: KWM2 = 777, KWM = 667 #define KWM2 666 #define KWM KWM2 #undef KWM2 - if (KWM .eq. 777) then + if (KWM .eq. 777) then print *, 'pp018.F yes' else print *, 'pp018.F no: ', KWM diff --git a/flang/test/Preprocessing/pp019.F b/flang/test/Preprocessing/pp019.F --- a/flang/test/Preprocessing/pp019.F +++ b/flang/test/Preprocessing/pp019.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((666)+111) +! CHECK: res = ((666)+111) * FLM rescan integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp020.F b/flang/test/Preprocessing/pp020.F --- a/flang/test/Preprocessing/pp020.F +++ b/flang/test/Preprocessing/pp020.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((111)+666) +! CHECK: res = ((111)+666) * FLM expansion of argument integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp021.F b/flang/test/Preprocessing/pp021.F --- a/flang/test/Preprocessing/pp021.F +++ b/flang/test/Preprocessing/pp021.F @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: ch='KWM' -! CHECK: if(ch.eq.'KWM')then +! CHECK: ch = 'KWM' +! CHECK: if (ch .eq. 'KWM') then * KWM NOT expanded in 'literal' #define KWM 666 character(len=3) :: ch diff --git a/flang/test/Preprocessing/pp022.F b/flang/test/Preprocessing/pp022.F --- a/flang/test/Preprocessing/pp022.F +++ b/flang/test/Preprocessing/pp022.F @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: ch="KWM" -! CHECK: if(ch.eq.'KWM')then +! CHECK: ch = "KWM" +! CHECK: if (ch .eq. 'KWM') then * KWM NOT expanded in "literal" #define KWM 666 character(len=3) :: ch diff --git a/flang/test/Preprocessing/pp023.F b/flang/test/Preprocessing/pp023.F --- a/flang/test/Preprocessing/pp023.F +++ b/flang/test/Preprocessing/pp023.F @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: ch=3hKWM -! CHECK: if(ch.eq.'KWM')then +! CHECK: ch = 3HKWM +! CHECK: if (ch .eq. 'KWM') then * KWM NOT expanded in 9HHOLLERITH literal #define KWM 666 #define HKWM 667 diff --git a/flang/test/Preprocessing/pp024.F b/flang/test/Preprocessing/pp024.F --- a/flang/test/Preprocessing/pp024.F +++ b/flang/test/Preprocessing/pp024.F @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: 100format(3hKWM) -! CHECK: if(ch.eq.'KWM')then +! CHECK: 100 format(3HKWM) +! CHECK: if (ch .eq. 'KWM') then * KWM NOT expanded in Hollerith in FORMAT #define KWM 666 #define HKWM 667 diff --git a/flang/test/Preprocessing/pp025.F b/flang/test/Preprocessing/pp025.F --- a/flang/test/Preprocessing/pp025.F +++ b/flang/test/Preprocessing/pp025.F @@ -1,10 +1,10 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=ikwm2z +! CHECK: res = I KWM2 Z * KWM expansion is before token pasting due to fixed-form space removal integer, parameter :: IKWM2Z = 777 #define KWM KWM2 integer :: res - res = I KWM Z + res = I KWM Z if (res .eq. 777) then print *, 'pp025.F yes' else diff --git a/flang/test/Preprocessing/pp026.F b/flang/test/Preprocessing/pp026.F --- a/flang/test/Preprocessing/pp026.F +++ b/flang/test/Preprocessing/pp026.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((111)+666) +! CHECK: res = ((111)+666) * ## token pasting works in FLM integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp027.F b/flang/test/Preprocessing/pp027.F --- a/flang/test/Preprocessing/pp027.F +++ b/flang/test/Preprocessing/pp027.F @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: kwm=666 -! CHECK: if(777.eq.777)then +! CHECK: KWM = 666 +! CHECK: if (777 .eq. 777) then * #DEFINE works in fixed form integer, parameter :: KWM = 666 #DEFINE KWM 777 diff --git a/flang/test/Preprocessing/pp028.F b/flang/test/Preprocessing/pp028.F --- a/flang/test/Preprocessing/pp028.F +++ b/flang/test/Preprocessing/pp028.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=kw +! CHECK: res = KW * fixed-form clipping done before KWM expansion on source line integer, parameter :: KW = 777 #define KWM 666 diff --git a/flang/test/Preprocessing/pp029.F b/flang/test/Preprocessing/pp029.F --- a/flang/test/Preprocessing/pp029.F +++ b/flang/test/Preprocessing/pp029.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777.eq.777)then +! CHECK: if (777 .eq. 777) then * \ newline allowed in #define integer, parameter :: KWM = 666 #define KWM 77\ diff --git a/flang/test/Preprocessing/pp030.F b/flang/test/Preprocessing/pp030.F --- a/flang/test/Preprocessing/pp030.F +++ b/flang/test/Preprocessing/pp030.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777.eq.777)then +! CHECK: if (777 .eq. 777) then * /* C comment */ erased from #define integer, parameter :: KWM = 666 #define KWM 777 /* C comment */ diff --git a/flang/test/Preprocessing/pp031.F b/flang/test/Preprocessing/pp031.F --- a/flang/test/Preprocessing/pp031.F +++ b/flang/test/Preprocessing/pp031.F @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777//ccomment.eq.777)then -! CHECK: print*,'pp031.F no: ',777//ccomment +! CHECK: if (777//Ccomment.eq.777)then +! CHECK: print *, 'pp031.F no: ', 777//Ccomment * // C++ comment NOT erased from #define integer, parameter :: KWM = 666 #define KWM 777 // C comment diff --git a/flang/test/Preprocessing/pp032.F b/flang/test/Preprocessing/pp032.F --- a/flang/test/Preprocessing/pp032.F +++ b/flang/test/Preprocessing/pp032.F @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777.eq.777)then -! CHECK: print*,'pp032.F no: ',777 +! CHECK: if (777 .eq. 777) then +! CHECK: print *, 'pp032.F no: ', 777 * /* C comment */ \ newline erased from #define integer, parameter :: KWM = 666 #define KWM 77/* C comment */\ diff --git a/flang/test/Preprocessing/pp033.F b/flang/test/Preprocessing/pp033.F --- a/flang/test/Preprocessing/pp033.F +++ b/flang/test/Preprocessing/pp033.F @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777.eq.777)then -! CHECK: print*,'pp033.F no: ',777 +! CHECK: if (777 .eq. 777) then +! CHECK: print *, 'pp033.F no: ', 777 * /* C comment \ newline */ erased from #define integer, parameter :: KWM = 666 #define KWM 77/* C comment \ diff --git a/flang/test/Preprocessing/pp034.F b/flang/test/Preprocessing/pp034.F --- a/flang/test/Preprocessing/pp034.F +++ b/flang/test/Preprocessing/pp034.F @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777.eq.777)then -! CHECK: print*,'pp034.F no: ',777 +! CHECK: if (777 .eq. 777) then +! CHECK: print *, 'pp034.F no: ', 777 * \ newline allowed in name on KWM definition integer, parameter :: KWMC = 666 #define KWM\ diff --git a/flang/test/Preprocessing/pp035.F b/flang/test/Preprocessing/pp035.F --- a/flang/test/Preprocessing/pp035.F +++ b/flang/test/Preprocessing/pp035.F @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777.eq.777)then -! CHECK: print*,'pp035.F no: ',777 +! CHECK: if (777 .eq. 777) then +! CHECK: print *, 'pp035.F no: ', 777 * #if 2 .LT. 3 works integer, parameter :: KWM = 666 #if 2 .LT. 3 diff --git a/flang/test/Preprocessing/pp036.F b/flang/test/Preprocessing/pp036.F --- a/flang/test/Preprocessing/pp036.F +++ b/flang/test/Preprocessing/pp036.F @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(.true.)then -! CHECK: print*,'pp036.F no: ',.true. +! CHECK: if (.TRUE .) then +! CHECK: print *, 'pp036.F no: ', .TRUE . * #define FALSE TRUE ... .FALSE. -> .TRUE. #define FALSE TRUE if (.FALSE.) then diff --git a/flang/test/Preprocessing/pp037.F b/flang/test/Preprocessing/pp037.F --- a/flang/test/Preprocessing/pp037.F +++ b/flang/test/Preprocessing/pp037.F @@ -1,12 +1,12 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(7777.eq.777)then -! CHECK: print*,'pp037.F no: ',7777 +! CHECK: if (7777 .eq. 777) then +! CHECK: print *, 'pp037.F no: ', 7777 * fixed-form clipping NOT applied to #define integer, parameter :: KWM = 666 * 1 2 3 4 5 6 7 *234567890123456789012345678901234567890123456789012345678901234567890123 #define KWM 7777 - if (KWM .eq. 777) then + if (KWM .eq. 777) then print *, 'pp037.F yes' else print *, 'pp037.F no: ', KWM diff --git a/flang/test/Preprocessing/pp038.F b/flang/test/Preprocessing/pp038.F --- a/flang/test/Preprocessing/pp038.F +++ b/flang/test/Preprocessing/pp038.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=((666)+111) +! CHECK: res = ((666)+111) * FLM call with closing ')' on next line (not a continuation) integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp039.F b/flang/test/Preprocessing/pp039.F --- a/flang/test/Preprocessing/pp039.F +++ b/flang/test/Preprocessing/pp039.F @@ -1,7 +1,7 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res=iflm +! CHECK: res = IFLM ! CHECK: (666) -! CHECK-NOT: res=((666)+111) +! CHECK-NOT: res = ((666)+111) * FLM call with '(' on next line (not a continuation) integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp041.F b/flang/test/Preprocessing/pp041.F --- a/flang/test/Preprocessing/pp041.F +++ b/flang/test/Preprocessing/pp041.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: j=666wmj=j+1wm211 +! CHECK: j = 666WMj=j+1WM211 * use KWM expansion as continuation indicators #define KWM 0 #define KWM2 1 diff --git a/flang/test/Preprocessing/pp043.F b/flang/test/Preprocessing/pp043.F --- a/flang/test/Preprocessing/pp043.F +++ b/flang/test/Preprocessing/pp043.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(kwm.eq.777)then +! CHECK: if (KWM .eq. 777) then * #define with # in column 6 is a continuation line in fixed-form integer, parameter :: defineKWM666 = 555 integer, parameter :: KWM = diff --git a/flang/test/Preprocessing/pp044.F b/flang/test/Preprocessing/pp044.F --- a/flang/test/Preprocessing/pp044.F +++ b/flang/test/Preprocessing/pp044.F @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK-NOT:z=111 +! CHECK-NOT:z = 111 * #define directive amid continuations integer, parameter :: KWM = 222, KWM111 = 333, KWM222 = 555 integer, parameter :: KWMKWM = 333 diff --git a/flang/test/Preprocessing/pp101.F90 b/flang/test/Preprocessing/pp101.F90 --- a/flang/test/Preprocessing/pp101.F90 +++ b/flang/test/Preprocessing/pp101.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777 .eq. 777) then +! CHECK: if (777 .eq. 777) then ! keyword macros integer, parameter :: KWM = 666 #define KWM 777 diff --git a/flang/test/Preprocessing/pp102.F90 b/flang/test/Preprocessing/pp102.F90 --- a/flang/test/Preprocessing/pp102.F90 +++ b/flang/test/Preprocessing/pp102.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(kwm .eq. 777) then +! CHECK: if (KWM .eq. 777) then ! #undef integer, parameter :: KWM = 777 #define KWM 666 diff --git a/flang/test/Preprocessing/pp104.F90 b/flang/test/Preprocessing/pp104.F90 --- a/flang/test/Preprocessing/pp104.F90 +++ b/flang/test/Preprocessing/pp104.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(kwm .eq. 777) then +! CHECK: if (kwm .eq. 777) then ! KWMs case-sensitive integer, parameter :: KWM = 777 #define KWM 666 diff --git a/flang/test/Preprocessing/pp107.F90 b/flang/test/Preprocessing/pp107.F90 --- a/flang/test/Preprocessing/pp107.F90 +++ b/flang/test/Preprocessing/pp107.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res = kwm +! CHECK: res = KWM ! KWM call name split across continuation, no leading &, with & ! comment integer, parameter :: KWM = 666 #define KWM 777 diff --git a/flang/test/Preprocessing/pp108.F90 b/flang/test/Preprocessing/pp108.F90 --- a/flang/test/Preprocessing/pp108.F90 +++ b/flang/test/Preprocessing/pp108.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res = kwm +! CHECK: res = KWM ! ditto, but without & ! comment integer, parameter :: KWM = 666 #define KWM 777 diff --git a/flang/test/Preprocessing/pp111.F90 b/flang/test/Preprocessing/pp111.F90 --- a/flang/test/Preprocessing/pp111.F90 +++ b/flang/test/Preprocessing/pp111.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res = iflm (666) +! CHECK: res = IFLM (666) ! FLM call name split across continuation, no leading &, with & ! comment integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp112.F90 b/flang/test/Preprocessing/pp112.F90 --- a/flang/test/Preprocessing/pp112.F90 +++ b/flang/test/Preprocessing/pp112.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res = iflm (666) +! CHECK: res = IFLM (666) ! ditto, but without & ! comment integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp115.F90 b/flang/test/Preprocessing/pp115.F90 --- a/flang/test/Preprocessing/pp115.F90 +++ b/flang/test/Preprocessing/pp115.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res = iflm (666) +! CHECK: res = IFLM (666) ! ditto, with & ! comment, no leading & integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp116.F90 b/flang/test/Preprocessing/pp116.F90 --- a/flang/test/Preprocessing/pp116.F90 +++ b/flang/test/Preprocessing/pp116.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res = iflm (666) +! CHECK: res = IFLM (666) ! FLM call split between name and (, no leading & integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp117.F90 b/flang/test/Preprocessing/pp117.F90 --- a/flang/test/Preprocessing/pp117.F90 +++ b/flang/test/Preprocessing/pp117.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777 .eq. 777) then +! CHECK: if (777 .eq. 777) then ! KWM rescan integer, parameter :: KWM = 666, KWM2 = 667 #define KWM2 777 diff --git a/flang/test/Preprocessing/pp118.F90 b/flang/test/Preprocessing/pp118.F90 --- a/flang/test/Preprocessing/pp118.F90 +++ b/flang/test/Preprocessing/pp118.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(kwm2 .eq. 777) then +! CHECK: if (KWM2 .eq. 777) then ! KWM rescan with #undef, proving rescan after expansion integer, parameter :: KWM2 = 777, KWM = 667 #define KWM2 666 diff --git a/flang/test/Preprocessing/pp121.F90 b/flang/test/Preprocessing/pp121.F90 --- a/flang/test/Preprocessing/pp121.F90 +++ b/flang/test/Preprocessing/pp121.F90 @@ -1,6 +1,6 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s ! CHECK: ch = 'KWM' -! CHECK: if(ch .eq. 'KWM') then +! CHECK: if (ch .eq. 'KWM') then ! KWM NOT expanded in 'literal' #define KWM 666 character(len=3) :: ch diff --git a/flang/test/Preprocessing/pp123.F90 b/flang/test/Preprocessing/pp123.F90 --- a/flang/test/Preprocessing/pp123.F90 +++ b/flang/test/Preprocessing/pp123.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: ch = 3hKWM +! CHECK: ch = 3HKWM ! KWM NOT expanded in Hollerith literal #define KWM 666 #define HKWM 667 diff --git a/flang/test/Preprocessing/pp124.F90 b/flang/test/Preprocessing/pp124.F90 --- a/flang/test/Preprocessing/pp124.F90 +++ b/flang/test/Preprocessing/pp124.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: 100 format(3hKWM) +! CHECK: 100 format(3HKWM) ! KWM NOT expanded in Hollerith in FORMAT #define KWM 666 #define HKWM 667 diff --git a/flang/test/Preprocessing/pp125.F90 b/flang/test/Preprocessing/pp125.F90 --- a/flang/test/Preprocessing/pp125.F90 +++ b/flang/test/Preprocessing/pp125.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777 .eq. 777) then +! CHECK: if (777 .eq. 777) then ! #DEFINE works in free form integer, parameter :: KWM = 666 #DEFINE KWM 777 diff --git a/flang/test/Preprocessing/pp126.F90 b/flang/test/Preprocessing/pp126.F90 --- a/flang/test/Preprocessing/pp126.F90 +++ b/flang/test/Preprocessing/pp126.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: if(777 .eq. 777) then +! CHECK: if (777 .eq. 777) then ! \ newline works in #define integer, parameter :: KWM = 666 #define KWM 77\ diff --git a/flang/test/Preprocessing/pp127.F90 b/flang/test/Preprocessing/pp127.F90 --- a/flang/test/Preprocessing/pp127.F90 +++ b/flang/test/Preprocessing/pp127.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res = iflm(666 ) +! CHECK: res = IFLM(666 ) ! FLM call with closing ')' on next line (not a continuation) integer function IFLM(x) integer :: x diff --git a/flang/test/Preprocessing/pp128.F90 b/flang/test/Preprocessing/pp128.F90 --- a/flang/test/Preprocessing/pp128.F90 +++ b/flang/test/Preprocessing/pp128.F90 @@ -1,5 +1,5 @@ ! RUN: %flang -E %s 2>&1 | FileCheck %s -! CHECK: res = iflm +! CHECK: res = IFLM ! FLM call with '(' on next line (not a continuation) integer function IFLM(x) integer :: x diff --git a/flang/tools/f18-parse-demo/f18-parse-demo.cpp b/flang/tools/f18-parse-demo/f18-parse-demo.cpp --- a/flang/tools/f18-parse-demo/f18-parse-demo.cpp +++ b/flang/tools/f18-parse-demo/f18-parse-demo.cpp @@ -87,9 +87,10 @@ bool warnOnNonstandardUsage{false}; // -Mstandard bool warningsAreErrors{false}; // -Werror Fortran::parser::Encoding encoding{Fortran::parser::Encoding::LATIN_1}; + bool lineDirectives{true}; // -P disables bool syntaxOnly{false}; bool dumpProvenance{false}; - bool dumpCookedChars{false}; + bool noReformat{false}; // -E -fno-reformat bool dumpUnparse{false}; bool dumpParseTree{false}; bool timeParse{false}; @@ -176,8 +177,13 @@ parsing.DumpProvenance(llvm::outs()); return {}; } - if (driver.dumpCookedChars) { - parsing.DumpCookedChars(llvm::outs()); + if (options.prescanAndReformat) { + parsing.messages().Emit(llvm::errs(), allCookedSources); + if (driver.noReformat) { + parsing.DumpCookedChars(llvm::outs()); + } else { + parsing.EmitPreprocessedSource(llvm::outs(), driver.lineDirectives); + } return {}; } parsing.Parse(llvm::outs()); @@ -302,7 +308,7 @@ while (!args.empty()) { std::string arg{std::move(args.front())}; args.pop_front(); - if (arg.empty()) { + if (arg.empty() || arg == "-Xflang") { } else if (arg.at(0) != '-') { anyFiles = true; auto dot{arg.rfind(".")}; @@ -353,8 +359,12 @@ driver.warningsAreErrors = true; } else if (arg == "-ed") { options.features.Enable(Fortran::common::LanguageFeature::OldDebugLines); - } else if (arg == "-E" || arg == "-fpreprocess-only") { - driver.dumpCookedChars = true; + } else if (arg == "-E") { + options.prescanAndReformat = true; + } else if (arg == "-P") { + driver.lineDirectives = false; + } else if (arg == "-fno-reformat") { + driver.noReformat = true; } else if (arg == "-fbackslash") { options.features.Enable( Fortran::common::LanguageFeature::BackslashEscapes); diff --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp --- a/flang/tools/f18/f18.cpp +++ b/flang/tools/f18/f18.cpp @@ -93,9 +93,10 @@ bool warningsAreErrors{false}; // -Werror bool byteswapio{false}; // -byteswapio Fortran::parser::Encoding encoding{Fortran::parser::Encoding::UTF_8}; + bool lineDirectives{true}; // -P disables bool syntaxOnly{false}; bool dumpProvenance{false}; - bool dumpCookedChars{false}; + bool noReformat{false}; // -E -fno-reformat bool dumpUnparse{false}; bool dumpUnparseWithSymbols{false}; bool dumpParseTree{false}; @@ -221,9 +222,13 @@ parsing.DumpProvenance(llvm::outs()); return {}; } - if (driver.dumpCookedChars) { + if (options.prescanAndReformat) { parsing.messages().Emit(llvm::errs(), allCookedSources); - parsing.DumpCookedChars(llvm::outs()); + if (driver.noReformat) { + parsing.DumpCookedChars(llvm::outs()); + } else { + parsing.EmitPreprocessedSource(llvm::outs(), driver.lineDirectives); + } return {}; } parsing.Parse(llvm::outs()); @@ -471,7 +476,7 @@ std::string suffix{arg.substr(dot + 1)}; std::string prefix{arg.substr(0, 2)}; args.pop_front(); - if (arg.empty()) { + if (arg.empty() || arg == "-Xflang") { } else if (arg.at(0) != '-') { anyFiles = true; if (dot == std::string::npos) { @@ -512,7 +517,8 @@ } else if (arg == "-Munlimited" || arg == "-ffree-line-length-none" || arg == "-ffree-line-length-0" || arg == "-ffixed-line-length-none" || arg == "-ffixed-line-length-0") { - // For reparsing f18's -E output of fixed-form cooked character stream + // For reparsing f18's -E -fno-reformat output of fixed-form + // cooked character stream options.fixedFormColumns = 1000000; } else if (arg == "-Mbackslash") { options.features.Enable( @@ -536,7 +542,11 @@ } else if (arg == "-ed") { options.features.Enable(Fortran::common::LanguageFeature::OldDebugLines); } else if (arg == "-E") { - driver.dumpCookedChars = true; + options.prescanAndReformat = true; + } else if (arg == "-P") { + driver.lineDirectives = false; + } else if (arg == "-fno-reformat") { + driver.noReformat = true; } else if (arg == "-fbackslash" || arg == "-fno-backslash") { options.features.Enable( Fortran::common::LanguageFeature::BackslashEscapes, diff --git a/flang/unittests/Frontend/FrontendActionTest.cpp b/flang/unittests/Frontend/FrontendActionTest.cpp --- a/flang/unittests/Frontend/FrontendActionTest.cpp +++ b/flang/unittests/Frontend/FrontendActionTest.cpp @@ -1,4 +1,4 @@ -//===- unittests/Frontend/PrintPreprocessedTest.cpp FrontendAction tests--===// +//===- unittests/Frontend/FrontendActionTest.cpp FrontendAction tests-----===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -116,6 +116,7 @@ // Set-up the action kind. compInst_.invocation().frontendOpts().programAction_ = PrintPreprocessedInput; + compInst_.invocation().preprocessorOpts().noReformat = true; // Set-up the output stream. We are using output buffer wrapped as an output // stream, as opposed to an actual file (or a file descriptor).