Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ 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]>, @@ -4532,6 +4532,8 @@ Group; def test_io : Flag<["-"], "test-io">, Group, HelpText<"Run the InputOuputTest action. Use for development and testing only.">; +def fdebug_dump_cooked_chars : Flag<["-"], "fdebug-dump-cooked-chars">, Group, + HelpText<"Dump the cooked character stream in -E mode">; def fdebug_unparse_no_sema : Flag<["-"], "fdebug-unparse-no-sema">, Group, HelpText<"Unparse and stop (skips the semantic checks)">, DocBrief<[{Only run the parser, then unparse the parse-tree and output the @@ -4562,7 +4564,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">; Index: clang/lib/Driver/ToolChains/Flang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Flang.cpp +++ clang/lib/Driver/ToolChains/Flang.cpp @@ -37,8 +37,10 @@ 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, + options::OPT_fdebug_dump_cooked_chars}); } void Flang::AddOtherOptions(const ArgList &Args, ArgStringList &CmdArgs) const { Index: flang/include/flang/Frontend/FrontendOptions.h =================================================================== --- flang/include/flang/Frontend/FrontendOptions.h +++ flang/include/flang/Frontend/FrontendOptions.h @@ -25,9 +25,12 @@ /// -test-io mode InputOutputTest, - /// -E mode. + /// -E mode PrintPreprocessedInput, + /// -fdebug-dump-cooked-chars + DebugDumpCookedChars, + /// -fsyntax-only ParseSyntaxOnly, @@ -249,6 +252,28 @@ // Source file encoding Fortran::parser::Encoding encoding_{Fortran::parser::Encoding::UTF_8}; +public: + // -P: Suppress #line directives in -E output + bool noLineDirectives() const { return noLineDirectives_; } + FrontendOptions &set_noLineDirectives(bool yes = true) { + noLineDirectives_ = yes; + return *this; + } + +private: + bool noLineDirectives_{false}; + +public: + // -fdebug-dump-cooked-chars: Emit cooked character stream as -E output + bool dumpCookedChars() const { return dumpCookedChars_; } + FrontendOptions &set_dumpCookedChars(bool yes = true) { + dumpCookedChars_ = yes; + return *this; + } + +private: + bool dumpCookedChars_{false}; + public: FrontendOptions() : showHelp_(false), showVersion_(false), instrumentedParse_(false), Index: flang/include/flang/Parser/parsing.h =================================================================== --- flang/include/flang/Parser/parsing.h +++ 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; Index: flang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- flang/lib/Frontend/CompilerInvocation.cpp +++ flang/lib/Frontend/CompilerInvocation.cpp @@ -119,6 +119,12 @@ break; case clang::driver::options::OPT_E: opts.programAction_ = PrintPreprocessedInput; + opts.set_noLineDirectives(args.hasArg(clang::driver::options::OPT_P)); + opts.set_dumpCookedChars( + args.hasArg(clang::driver::options::OPT_fdebug_dump_cooked_chars)); + break; + case clang::driver::options::OPT_fdebug_dump_cooked_chars: + opts.programAction_ = DebugDumpCookedChars; break; case clang::driver::options::OPT_fsyntax_only: opts.programAction_ = ParseSyntaxOnly; Index: flang/lib/Frontend/FrontendActions.cpp =================================================================== --- flang/lib/Frontend/FrontendActions.cpp +++ 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().frontendOpts().dumpCookedChars()) { + ci.parsing().DumpCookedChars(outForPP); + } else { + ci.parsing().EmitPreprocessedSource( + outForPP, !ci.invocation().frontendOpts().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; } } Index: flang/lib/Frontend/FrontendOptions.cpp =================================================================== --- flang/lib/Frontend/FrontendOptions.cpp +++ flang/lib/Frontend/FrontendOptions.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "flang/Frontend/FrontendOptions.h" -#include "flang/Evaluate/expression.h" using namespace Fortran::frontend; Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp =================================================================== --- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ 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: Index: flang/lib/Parser/parsing.cpp =================================================================== --- flang/lib/Parser/parsing.cpp +++ flang/lib/Parser/parsing.cpp @@ -95,6 +95,87 @@ return sourceFile; } +void Parsing::EmitPreprocessedSource( + llvm::raw_ostream &out, bool lineDirectives) const { + const SourceFile *sourceFile{nullptr}; + int sourceLine{0}; + int column{1}; + static int constexpr columnLimit{72}; + 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 == '!') { + 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 > columnLimit) { + // Wrap long lines in a portable fashion. + // Use the standard Fortran fixed form column limit for output, + // even if it was parsed with a nonstandard column limit. + out << "&\n &"; + column = 7; + ++sourceLine; + inContinuation = true; + } else if (!inDirective && column < 7 && ch != ' ' && + (ch < '0' || ch > '9')) { + for (; column < 7; ++column) { + out << ' '; + } + } + if (!inContinuation && position && position->column <= columnLimit && + 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()}; Index: flang/lib/Parser/provenance.cpp =================================================================== --- flang/lib/Parser/provenance.cpp +++ flang/lib/Parser/provenance.cpp @@ -593,7 +593,7 @@ return result; } } - return nullptr; + return std::nullopt; } void AllCookedSources::Dump(llvm::raw_ostream &o) const { Index: flang/test/Driver/cpp-nocpp-command-line-macro.f90 =================================================================== --- flang/test/Driver/cpp-nocpp-command-line-macro.f90 +++ flang/test/Driver/cpp-nocpp-command-line-macro.f90 @@ -1,9 +1,9 @@ !----------- ! RUN lines !----------- -! RUN: %flang_fc1 -E %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED -! RUN: %flang_fc1 -E -cpp -DX=A %s 2>&1 | FileCheck %s --check-prefix=DEFINED -! RUN: %flang_fc1 -E -nocpp -DX=A %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -cpp -DX=A %s 2>&1 | FileCheck %s --check-prefix=DEFINED +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -nocpp -DX=A %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED !----------------- ! EXPECTED OUTPUT Index: flang/test/Driver/driver-help-hidden.f90 =================================================================== --- flang/test/Driver/driver-help-hidden.f90 +++ 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 Index: flang/test/Driver/driver-help.f90 =================================================================== --- flang/test/Driver/driver-help.f90 +++ 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 @@ -70,6 +71,8 @@ ! HELP-FC1-NEXT: Enable the old style PARAMETER statement ! HELP-FC1-NEXT: -fbackslash Specify that backslash in string introduces an escape character ! HELP-FC1-NEXT: -fdebug-dump-all Dump symbols and the parse tree after the semantic checks +! HELP-FC1-NEXT: -fdebug-dump-cooked-chars +! HELP-FC1-NEXT: Dump the cooked character stream in -E mode ! HELP-FC1-NEXT: -fdebug-dump-parse-tree-no-sema ! HELP-FC1-NEXT: Dump the parse tree (skips the semantic checks) ! HELP-FC1-NEXT: -fdebug-dump-parse-tree Dump the parse tree @@ -114,6 +117,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 Index: flang/test/Driver/escaped-backslash.f90 =================================================================== --- flang/test/Driver/escaped-backslash.f90 +++ flang/test/Driver/escaped-backslash.f90 @@ -3,16 +3,16 @@ !-------------------------- ! FLANG DRIVER (flang-new) !-------------------------- -! RUN: %flang -E %s 2>&1 | FileCheck %s --check-prefix=ESCAPED -! RUN: %flang -E -fbackslash -fno-backslash %s 2>&1 | FileCheck %s --check-prefix=ESCAPED -! RUN: %flang -E -fbackslash %s 2>&1 | FileCheck %s --check-prefix=UNESCAPED +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s --check-prefix=ESCAPED +! RUN: %flang -E -fdebug-dump-cooked-chars -fbackslash -fno-backslash %s 2>&1 | FileCheck %s --check-prefix=ESCAPED +! RUN: %flang -E -fdebug-dump-cooked-chars -fbackslash %s 2>&1 | FileCheck %s --check-prefix=UNESCAPED !----------------------------------------- ! FRONTEND FLANG DRIVER (flang-new -fc1) !----------------------------------------- -! RUN: %flang_fc1 -E %s 2>&1 | FileCheck %s --check-prefix=ESCAPED -! RUN: %flang_fc1 -E -fbackslash -fno-backslash %s 2>&1 | FileCheck %s --check-prefix=ESCAPED -! RUN: %flang_fc1 -E -fbackslash %s 2>&1 | FileCheck %s --check-prefix=UNESCAPED +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s --check-prefix=ESCAPED +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -fbackslash -fno-backslash %s 2>&1 | FileCheck %s --check-prefix=ESCAPED +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -fbackslash %s 2>&1 | FileCheck %s --check-prefix=UNESCAPED !----------------------------------------- ! EXPECTED OUTPUT FOR ESCAPED BACKSLASHES Index: flang/test/Driver/fixed-free-detection.f90 =================================================================== --- flang/test/Driver/fixed-free-detection.f90 +++ flang/test/Driver/fixed-free-detection.f90 @@ -5,16 +5,16 @@ !-------------------------- ! 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 -fdebug-dump-cooked-chars %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FREEFORM +! RUN: %flang -E -fdebug-dump-cooked-chars %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=FIXEDFORM +! RUN: %flang -E -fdebug-dump-cooked-chars %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 -fdebug-dump-cooked-chars %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FREEFORM +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars %S/Inputs/fixed-form-test.f 2>&1 | FileCheck %s --check-prefix=FIXEDFORM +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars %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 Index: flang/test/Driver/fixed-line-length.f90 =================================================================== --- flang/test/Driver/fixed-line-length.f90 +++ 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 -fdebug-dump-cooked-chars %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH +! RUN: not %flang -E -fdebug-dump-cooked-chars -ffixed-line-length=-2 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=NEGATIVELENGTH +! RUN: not %flang -E -fdebug-dump-cooked-chars -ffixed-line-length=3 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH +! RUN: %flang -E -fdebug-dump-cooked-chars -ffixed-line-length=none %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH +! RUN: %flang -E -fdebug-dump-cooked-chars -ffixed-line-length=0 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH +! RUN: %flang -E -fdebug-dump-cooked-chars -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 -fdebug-dump-cooked-chars %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH +! RUN: not %flang_fc1 -E -fdebug-dump-cooked-chars -ffixed-line-length=-2 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=NEGATIVELENGTH +! RUN: not %flang_fc1 -E -fdebug-dump-cooked-chars -ffixed-line-length=3 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -ffixed-line-length=none %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -ffixed-line-length=0 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -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 -fdebug-dump-cooked-chars -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=LENGTH13 +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f 2>&1 | FileCheck %s --check-prefix=LENGTH13 !------------------------------------- ! EXPECTED OUTPUT WITH DEFAULT LENGTH Index: flang/test/Driver/include-header.f90 =================================================================== --- flang/test/Driver/include-header.f90 +++ flang/test/Driver/include-header.f90 @@ -3,18 +3,18 @@ !-------------------------- ! FLANG DRIVER (flang) !-------------------------- -! RUN: not %flang -E %s 2>&1 | FileCheck %s --check-prefix=UNINCLUDED -! RUN: %flang -E -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE -! RUN: %flang -E -I %S/Inputs -I %S/Inputs/header-dir %s 2>&1 | FileCheck %s --check-prefix=MAINDIRECTORY -! RUN: %flang -E -I %S/Inputs/header-dir -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SUBDIRECTORY +! RUN: not %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s --check-prefix=UNINCLUDED +! RUN: %flang -E -fdebug-dump-cooked-chars -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE +! RUN: %flang -E -fdebug-dump-cooked-chars -I %S/Inputs -I %S/Inputs/header-dir %s 2>&1 | FileCheck %s --check-prefix=MAINDIRECTORY +! RUN: %flang -E -fdebug-dump-cooked-chars -I %S/Inputs/header-dir -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SUBDIRECTORY !---------------------------------------- ! FRONTEND FLANG DRIVER (flang_fc1) !---------------------------------------- -! RUN: not %flang_fc1 -E %s 2>&1 | FileCheck %s --check-prefix=UNINCLUDED -! RUN: %flang_fc1 -E -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE -! RUN: %flang_fc1 -E -I %S/Inputs -I %S/Inputs/header-dir %s 2>&1 | FileCheck %s --check-prefix=MAINDIRECTORY -! RUN: %flang_fc1 -E -I %S/Inputs/header-dir -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SUBDIRECTORY +! RUN: not %flang_fc1 -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s --check-prefix=UNINCLUDED +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -I %S/Inputs -I %S/Inputs/header-dir %s 2>&1 | FileCheck %s --check-prefix=MAINDIRECTORY +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -I %S/Inputs/header-dir -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SUBDIRECTORY !-------------------------------------------- ! EXPECTED OUTPUT FOR MISSING INCLUDED FILE Index: flang/test/Driver/input-from-stdin.f90 =================================================================== --- flang/test/Driver/input-from-stdin.f90 +++ flang/test/Driver/input-from-stdin.f90 @@ -6,21 +6,21 @@ ! FLANG DRIVER (flang) !-------------------------- ! Input type is implicit -! RUN: cat %s | %flang -E -cpp - | FileCheck %s --check-prefix=PP-NOT-DEFINED -! RUN: cat %s | %flang -DNEW -E -cpp - | FileCheck %s --check-prefix=PP-DEFINED -! RUN: cat %s | %flang -DNEW -E - | FileCheck %s --check-prefix=PP-NOT-DEFINED -! RUN: cat %s | %flang -DNEW -E -nocpp - | FileCheck %s --check-prefix=PP-NOT-DEFINED +! RUN: cat %s | %flang -E -fdebug-dump-cooked-chars -cpp - | FileCheck %s --check-prefix=PP-NOT-DEFINED +! RUN: cat %s | %flang -DNEW -E -fdebug-dump-cooked-chars -cpp - | FileCheck %s --check-prefix=PP-DEFINED +! RUN: cat %s | %flang -DNEW -E -fdebug-dump-cooked-chars - | FileCheck %s --check-prefix=PP-NOT-DEFINED +! RUN: cat %s | %flang -DNEW -E -fdebug-dump-cooked-chars -nocpp - | FileCheck %s --check-prefix=PP-NOT-DEFINED ! Input type is explicit -! RUN: cat %s | %flang -E -cpp -x f95-cpp-input - | FileCheck %s --check-prefix=PP-NOT-DEFINED -! RUN: cat %s | %flang -DNEW -E -cpp -x f95-cpp-input - | FileCheck %s --check-prefix=PP-DEFINED +! RUN: cat %s | %flang -E -fdebug-dump-cooked-chars -cpp -x f95-cpp-input - | FileCheck %s --check-prefix=PP-NOT-DEFINED +! RUN: cat %s | %flang -DNEW -E -fdebug-dump-cooked-chars -cpp -x f95-cpp-input - | FileCheck %s --check-prefix=PP-DEFINED !--------------------------------------- ! FLANG FRONTEND DRIVER (flang -fc1) !--------------------------------------- ! Test `-E`: for the corresponding frontend actions the driver relies on the prescanner API to handle file I/O -! RUN: cat %s | %flang -fc1 -E -cpp | FileCheck %s --check-prefix=PP-NOT-DEFINED -! RUN: cat %s | %flang -fc1 -DNEW -E -cpp | FileCheck %s --check-prefix=PP-DEFINED +! RUN: cat %s | %flang -fc1 -E -fdebug-dump-cooked-chars -cpp | FileCheck %s --check-prefix=PP-NOT-DEFINED +! RUN: cat %s | %flang -fc1 -DNEW -E -fdebug-dump-cooked-chars -cpp | FileCheck %s --check-prefix=PP-DEFINED ! Test `-test-io`: for the corresponding frontend action (`InputOutputTestAction`) the driver handles the file I/O on its own ! the corresponding action (`PrintPreprocessedAction`) Index: flang/test/Driver/macro-def-undef.F90 =================================================================== --- flang/test/Driver/macro-def-undef.F90 +++ flang/test/Driver/macro-def-undef.F90 @@ -3,16 +3,16 @@ !-------------------------- ! 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 -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED +! RUN: %flang -E -fdebug-dump-cooked-chars -DX=A %s 2>&1 | FileCheck %s --check-prefix=DEFINED +! RUN: %flang -E -fdebug-dump-cooked-chars -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 -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -DX=A %s 2>&1 | FileCheck %s --check-prefix=DEFINED +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars -DX -UX %s 2>&1 | FileCheck %s --check-prefix=UNDEFINED !-------------------------------------------- ! EXPECTED OUTPUT FOR AN UNDEFINED MACRO Index: flang/test/Driver/macro-multiline.F90 =================================================================== --- flang/test/Driver/macro-multiline.F90 +++ flang/test/Driver/macro-multiline.F90 @@ -5,12 +5,12 @@ !-------------------------- ! 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 -fdebug-dump-cooked-chars %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 -fdebug-dump-cooked-chars %s 2>&1 | FileCheck --strict-whitespace --match-full-lines %s !------------------------------- ! EXPECTED OUTPUT FOR MACRO 'X' Index: flang/test/Parser/badlabel.f =================================================================== --- flang/test/Parser/badlabel.f +++ flang/test/Parser/badlabel.f @@ -1,4 +1,4 @@ -! RUN: %flang_fc1 -E %s 2>&1 | FileCheck %s +! RUN: %flang_fc1 -E -fdebug-dump-cooked-chars %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 Index: flang/test/Preprocessing/assert.F90 =================================================================== --- flang/test/Preprocessing/assert.F90 +++ flang/test/Preprocessing/assert.F90 @@ -1,4 +1,4 @@ -!RUN: %flang -E %s 2>&1 | FileCheck %s +!RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s !CHECK: if(.not.(.true.)) error stop "assert(" // ".TRUE." // ") failed " // "at "" !CHECK-SAME: assert.F90"": " // "7" #define STR(x) #x Index: flang/test/Preprocessing/dash-E.F90 =================================================================== --- /dev/null +++ flang/test/Preprocessing/dash-E.F90 @@ -0,0 +1,25 @@ +! RUN: %flang -E %s 2>&1 | FileCheck %s +#define ADD(x,y) (x)+(y) +!CHECK: program Main +program Main +!CHECK: integer :: j = (1)+( 2) + integer :: j = ADD(1,& + 2) +!CHECK: for a F& +!CHECK: &ORMAT statement +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 Index: flang/test/Preprocessing/hollerith.f =================================================================== --- flang/test/Preprocessing/hollerith.f +++ flang/test/Preprocessing/hollerith.f @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: character*1hi ! CHECK: dataa/1*1h / ! CHECK: datab/1*1h / Index: flang/test/Preprocessing/pp001.F =================================================================== --- flang/test/Preprocessing/pp001.F +++ flang/test/Preprocessing/pp001.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777.eq.777)then * keyword macros integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp002.F =================================================================== --- flang/test/Preprocessing/pp002.F +++ flang/test/Preprocessing/pp002.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(kwm.eq.777)then * #undef integer, parameter :: KWM = 777 Index: flang/test/Preprocessing/pp003.F =================================================================== --- flang/test/Preprocessing/pp003.F +++ flang/test/Preprocessing/pp003.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((666)+111) * function-like macros integer function IFLM(x) Index: flang/test/Preprocessing/pp004.F =================================================================== --- flang/test/Preprocessing/pp004.F +++ flang/test/Preprocessing/pp004.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(kwm.eq.777)then * KWMs case-sensitive integer, parameter :: KWM = 777 Index: flang/test/Preprocessing/pp005.F =================================================================== --- flang/test/Preprocessing/pp005.F +++ flang/test/Preprocessing/pp005.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=777 * KWM split across continuation, implicit padding integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp006.F =================================================================== --- flang/test/Preprocessing/pp006.F +++ flang/test/Preprocessing/pp006.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=777 * ditto, but with intervening *comment line integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp007.F =================================================================== --- flang/test/Preprocessing/pp007.F +++ flang/test/Preprocessing/pp007.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=kwm * KWM split across continuation, clipped after column 72 integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp008.F =================================================================== --- flang/test/Preprocessing/pp008.F +++ flang/test/Preprocessing/pp008.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=kwm * KWM with spaces in name at invocation NOT replaced integer, parameter :: KWM = 777 Index: flang/test/Preprocessing/pp009.F =================================================================== --- flang/test/Preprocessing/pp009.F +++ flang/test/Preprocessing/pp009.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((666)+111) * FLM call split across continuation, implicit padding integer function IFLM(x) Index: flang/test/Preprocessing/pp010.F =================================================================== --- flang/test/Preprocessing/pp010.F +++ flang/test/Preprocessing/pp010.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((666)+111) * ditto, but with intervening *comment line integer function IFLM(x) Index: flang/test/Preprocessing/pp011.F =================================================================== --- flang/test/Preprocessing/pp011.F +++ flang/test/Preprocessing/pp011.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=iflm(666) * FLM call name split across continuation, clipped integer function IFLM(x) Index: flang/test/Preprocessing/pp012.F =================================================================== --- flang/test/Preprocessing/pp012.F +++ flang/test/Preprocessing/pp012.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((666)+111) * FLM call name split across continuation integer function IFLM(x) Index: flang/test/Preprocessing/pp013.F =================================================================== --- flang/test/Preprocessing/pp013.F +++ flang/test/Preprocessing/pp013.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((666)+111) * FLM call split between name and ( integer function IFLM(x) Index: flang/test/Preprocessing/pp014.F =================================================================== --- flang/test/Preprocessing/pp014.F +++ flang/test/Preprocessing/pp014.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((666)+111) * FLM call split between name and (, with intervening *comment integer function IFLM(x) Index: flang/test/Preprocessing/pp015.F =================================================================== --- flang/test/Preprocessing/pp015.F +++ flang/test/Preprocessing/pp015.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((666)+111) * FLM call split between name and (, clipped integer function IFLM(x) Index: flang/test/Preprocessing/pp016.F =================================================================== --- flang/test/Preprocessing/pp016.F +++ flang/test/Preprocessing/pp016.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((666)+111) * FLM call split between name and ( and in argument integer function IFLM(x) Index: flang/test/Preprocessing/pp017.F =================================================================== --- flang/test/Preprocessing/pp017.F +++ flang/test/Preprocessing/pp017.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777.eq.777)then * KLM rescan integer, parameter :: KWM = 666, KWM2 = 667 Index: flang/test/Preprocessing/pp018.F =================================================================== --- flang/test/Preprocessing/pp018.F +++ flang/test/Preprocessing/pp018.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(kwm2.eq.777)then * KLM rescan with #undef (so rescan is after expansion) integer, parameter :: KWM2 = 777, KWM = 667 Index: flang/test/Preprocessing/pp019.F =================================================================== --- flang/test/Preprocessing/pp019.F +++ flang/test/Preprocessing/pp019.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((666)+111) * FLM rescan integer function IFLM(x) Index: flang/test/Preprocessing/pp020.F =================================================================== --- flang/test/Preprocessing/pp020.F +++ flang/test/Preprocessing/pp020.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((111)+666) * FLM expansion of argument integer function IFLM(x) Index: flang/test/Preprocessing/pp021.F =================================================================== --- flang/test/Preprocessing/pp021.F +++ flang/test/Preprocessing/pp021.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: ch='KWM' ! CHECK: if(ch.eq.'KWM')then * KWM NOT expanded in 'literal' Index: flang/test/Preprocessing/pp022.F =================================================================== --- flang/test/Preprocessing/pp022.F +++ flang/test/Preprocessing/pp022.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: ch="KWM" ! CHECK: if(ch.eq.'KWM')then * KWM NOT expanded in "literal" Index: flang/test/Preprocessing/pp023.F =================================================================== --- flang/test/Preprocessing/pp023.F +++ flang/test/Preprocessing/pp023.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: ch=3hKWM ! CHECK: if(ch.eq.'KWM')then * KWM NOT expanded in 9HHOLLERITH literal Index: flang/test/Preprocessing/pp024.F =================================================================== --- flang/test/Preprocessing/pp024.F +++ flang/test/Preprocessing/pp024.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: 100format(3hKWM) ! CHECK: if(ch.eq.'KWM')then * KWM NOT expanded in Hollerith in FORMAT Index: flang/test/Preprocessing/pp025.F =================================================================== --- flang/test/Preprocessing/pp025.F +++ flang/test/Preprocessing/pp025.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=ikwm2z * KWM expansion is before token pasting due to fixed-form space removal integer, parameter :: IKWM2Z = 777 Index: flang/test/Preprocessing/pp026.F =================================================================== --- flang/test/Preprocessing/pp026.F +++ flang/test/Preprocessing/pp026.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((111)+666) * ## token pasting works in FLM integer function IFLM(x) Index: flang/test/Preprocessing/pp027.F =================================================================== --- flang/test/Preprocessing/pp027.F +++ flang/test/Preprocessing/pp027.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: kwm=666 ! CHECK: if(777.eq.777)then * #DEFINE works in fixed form Index: flang/test/Preprocessing/pp028.F =================================================================== --- flang/test/Preprocessing/pp028.F +++ flang/test/Preprocessing/pp028.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=kw * fixed-form clipping done before KWM expansion on source line integer, parameter :: KW = 777 Index: flang/test/Preprocessing/pp029.F =================================================================== --- flang/test/Preprocessing/pp029.F +++ flang/test/Preprocessing/pp029.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777.eq.777)then * \ newline allowed in #define integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp030.F =================================================================== --- flang/test/Preprocessing/pp030.F +++ flang/test/Preprocessing/pp030.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777.eq.777)then * /* C comment */ erased from #define integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp031.F =================================================================== --- flang/test/Preprocessing/pp031.F +++ flang/test/Preprocessing/pp031.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777//ccomment.eq.777)then ! CHECK: print*,'pp031.F no: ',777//ccomment * // C++ comment NOT erased from #define Index: flang/test/Preprocessing/pp032.F =================================================================== --- flang/test/Preprocessing/pp032.F +++ flang/test/Preprocessing/pp032.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777.eq.777)then ! CHECK: print*,'pp032.F no: ',777 * /* C comment */ \ newline erased from #define Index: flang/test/Preprocessing/pp033.F =================================================================== --- flang/test/Preprocessing/pp033.F +++ flang/test/Preprocessing/pp033.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777.eq.777)then ! CHECK: print*,'pp033.F no: ',777 * /* C comment \ newline */ erased from #define Index: flang/test/Preprocessing/pp034.F =================================================================== --- flang/test/Preprocessing/pp034.F +++ flang/test/Preprocessing/pp034.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777.eq.777)then ! CHECK: print*,'pp034.F no: ',777 * \ newline allowed in name on KWM definition Index: flang/test/Preprocessing/pp035.F =================================================================== --- flang/test/Preprocessing/pp035.F +++ flang/test/Preprocessing/pp035.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777.eq.777)then ! CHECK: print*,'pp035.F no: ',777 * #if 2 .LT. 3 works Index: flang/test/Preprocessing/pp036.F =================================================================== --- flang/test/Preprocessing/pp036.F +++ flang/test/Preprocessing/pp036.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(.true.)then ! CHECK: print*,'pp036.F no: ',.true. * #define FALSE TRUE ... .FALSE. -> .TRUE. Index: flang/test/Preprocessing/pp037.F =================================================================== --- flang/test/Preprocessing/pp037.F +++ flang/test/Preprocessing/pp037.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(7777.eq.777)then ! CHECK: print*,'pp037.F no: ',7777 * fixed-form clipping NOT applied to #define Index: flang/test/Preprocessing/pp038.F =================================================================== --- flang/test/Preprocessing/pp038.F +++ flang/test/Preprocessing/pp038.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=((666)+111) * FLM call with closing ')' on next line (not a continuation) integer function IFLM(x) Index: flang/test/Preprocessing/pp039.F =================================================================== --- flang/test/Preprocessing/pp039.F +++ flang/test/Preprocessing/pp039.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res=iflm ! CHECK: (666) ! CHECK-NOT: res=((666)+111) Index: flang/test/Preprocessing/pp040.F =================================================================== --- flang/test/Preprocessing/pp040.F +++ flang/test/Preprocessing/pp040.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK-NOT: FAIL HARD! * #define KWM c, then KWM works as comment line initiator #define KWM c Index: flang/test/Preprocessing/pp041.F =================================================================== --- flang/test/Preprocessing/pp041.F +++ flang/test/Preprocessing/pp041.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: j=666wmj=j+1wm211 * use KWM expansion as continuation indicators #define KWM 0 Index: flang/test/Preprocessing/pp042.F =================================================================== --- flang/test/Preprocessing/pp042.F +++ flang/test/Preprocessing/pp042.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK-NOT: goto 2 * #define c 1, then use c as label in fixed-form #define c 1 Index: flang/test/Preprocessing/pp043.F =================================================================== --- flang/test/Preprocessing/pp043.F +++ flang/test/Preprocessing/pp043.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(kwm.eq.777)then * #define with # in column 6 is a continuation line in fixed-form integer, parameter :: defineKWM666 = 555 Index: flang/test/Preprocessing/pp044.F =================================================================== --- flang/test/Preprocessing/pp044.F +++ flang/test/Preprocessing/pp044.F @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK-NOT:z=111 * #define directive amid continuations integer, parameter :: KWM = 222, KWM111 = 333, KWM222 = 555 Index: flang/test/Preprocessing/pp101.F90 =================================================================== --- flang/test/Preprocessing/pp101.F90 +++ flang/test/Preprocessing/pp101.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777 .eq. 777) then ! keyword macros integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp102.F90 =================================================================== --- flang/test/Preprocessing/pp102.F90 +++ flang/test/Preprocessing/pp102.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(kwm .eq. 777) then ! #undef integer, parameter :: KWM = 777 Index: flang/test/Preprocessing/pp103.F90 =================================================================== --- flang/test/Preprocessing/pp103.F90 +++ flang/test/Preprocessing/pp103.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = ((666)+111) ! function-like macros integer function IFLM(x) Index: flang/test/Preprocessing/pp104.F90 =================================================================== --- flang/test/Preprocessing/pp104.F90 +++ flang/test/Preprocessing/pp104.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(kwm .eq. 777) then ! KWMs case-sensitive integer, parameter :: KWM = 777 Index: flang/test/Preprocessing/pp105.F90 =================================================================== --- flang/test/Preprocessing/pp105.F90 +++ flang/test/Preprocessing/pp105.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = 777 ! KWM call name split across continuation, with leading & integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp106.F90 =================================================================== --- flang/test/Preprocessing/pp106.F90 +++ flang/test/Preprocessing/pp106.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = 777 ! ditto, with & ! comment integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp107.F90 =================================================================== --- flang/test/Preprocessing/pp107.F90 +++ flang/test/Preprocessing/pp107.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = kwm ! KWM call name split across continuation, no leading &, with & ! comment integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp108.F90 =================================================================== --- flang/test/Preprocessing/pp108.F90 +++ flang/test/Preprocessing/pp108.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = kwm ! ditto, but without & ! comment integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp109.F90 =================================================================== --- flang/test/Preprocessing/pp109.F90 +++ flang/test/Preprocessing/pp109.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = ((666)+111) ! FLM call name split with leading & integer function IFLM(x) Index: flang/test/Preprocessing/pp110.F90 =================================================================== --- flang/test/Preprocessing/pp110.F90 +++ flang/test/Preprocessing/pp110.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = ((666)+111) ! ditto, with & ! comment integer function IFLM(x) Index: flang/test/Preprocessing/pp111.F90 =================================================================== --- flang/test/Preprocessing/pp111.F90 +++ flang/test/Preprocessing/pp111.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = iflm (666) ! FLM call name split across continuation, no leading &, with & ! comment integer function IFLM(x) Index: flang/test/Preprocessing/pp112.F90 =================================================================== --- flang/test/Preprocessing/pp112.F90 +++ flang/test/Preprocessing/pp112.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = iflm (666) ! ditto, but without & ! comment integer function IFLM(x) Index: flang/test/Preprocessing/pp113.F90 =================================================================== --- flang/test/Preprocessing/pp113.F90 +++ flang/test/Preprocessing/pp113.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = ((666)+111) ! FLM call split across continuation between name and (, leading & integer function IFLM(x) Index: flang/test/Preprocessing/pp114.F90 =================================================================== --- flang/test/Preprocessing/pp114.F90 +++ flang/test/Preprocessing/pp114.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = ((666)+111) ! ditto, with & ! comment, leading & integer function IFLM(x) Index: flang/test/Preprocessing/pp115.F90 =================================================================== --- flang/test/Preprocessing/pp115.F90 +++ flang/test/Preprocessing/pp115.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = iflm (666) ! ditto, with & ! comment, no leading & integer function IFLM(x) Index: flang/test/Preprocessing/pp116.F90 =================================================================== --- flang/test/Preprocessing/pp116.F90 +++ flang/test/Preprocessing/pp116.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = iflm (666) ! FLM call split between name and (, no leading & integer function IFLM(x) Index: flang/test/Preprocessing/pp117.F90 =================================================================== --- flang/test/Preprocessing/pp117.F90 +++ flang/test/Preprocessing/pp117.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777 .eq. 777) then ! KWM rescan integer, parameter :: KWM = 666, KWM2 = 667 Index: flang/test/Preprocessing/pp118.F90 =================================================================== --- flang/test/Preprocessing/pp118.F90 +++ flang/test/Preprocessing/pp118.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(kwm2 .eq. 777) then ! KWM rescan with #undef, proving rescan after expansion integer, parameter :: KWM2 = 777, KWM = 667 Index: flang/test/Preprocessing/pp119.F90 =================================================================== --- flang/test/Preprocessing/pp119.F90 +++ flang/test/Preprocessing/pp119.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = ((666)+111) ! FLM rescan integer function IFLM(x) Index: flang/test/Preprocessing/pp120.F90 =================================================================== --- flang/test/Preprocessing/pp120.F90 +++ flang/test/Preprocessing/pp120.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = ((111)+666) ! FLM expansion of argument integer function IFLM(x) Index: flang/test/Preprocessing/pp121.F90 =================================================================== --- flang/test/Preprocessing/pp121.F90 +++ flang/test/Preprocessing/pp121.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: ch = 'KWM' ! CHECK: if(ch .eq. 'KWM') then ! KWM NOT expanded in 'literal' Index: flang/test/Preprocessing/pp122.F90 =================================================================== --- flang/test/Preprocessing/pp122.F90 +++ flang/test/Preprocessing/pp122.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: ch = "KWM" ! KWM NOT expanded in "literal" #define KWM 666 Index: flang/test/Preprocessing/pp123.F90 =================================================================== --- flang/test/Preprocessing/pp123.F90 +++ flang/test/Preprocessing/pp123.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: ch = 3hKWM ! KWM NOT expanded in Hollerith literal #define KWM 666 Index: flang/test/Preprocessing/pp124.F90 =================================================================== --- flang/test/Preprocessing/pp124.F90 +++ flang/test/Preprocessing/pp124.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: 100 format(3hKWM) ! KWM NOT expanded in Hollerith in FORMAT #define KWM 666 Index: flang/test/Preprocessing/pp125.F90 =================================================================== --- flang/test/Preprocessing/pp125.F90 +++ flang/test/Preprocessing/pp125.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777 .eq. 777) then ! #DEFINE works in free form integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp126.F90 =================================================================== --- flang/test/Preprocessing/pp126.F90 +++ flang/test/Preprocessing/pp126.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: if(777 .eq. 777) then ! \ newline works in #define integer, parameter :: KWM = 666 Index: flang/test/Preprocessing/pp127.F90 =================================================================== --- flang/test/Preprocessing/pp127.F90 +++ flang/test/Preprocessing/pp127.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = iflm(666 ) ! FLM call with closing ')' on next line (not a continuation) integer function IFLM(x) Index: flang/test/Preprocessing/pp128.F90 =================================================================== --- flang/test/Preprocessing/pp128.F90 +++ flang/test/Preprocessing/pp128.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: res = iflm ! FLM call with '(' on next line (not a continuation) integer function IFLM(x) Index: flang/test/Preprocessing/pp129.F90 =================================================================== --- flang/test/Preprocessing/pp129.F90 +++ flang/test/Preprocessing/pp129.F90 @@ -1,4 +1,4 @@ -! RUN: %flang -E %s 2>&1 | FileCheck %s +! RUN: %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK-NOT: stop ! #define KWM !, then KWM works as comment line initiator #define KWM ! Index: flang/test/Preprocessing/pp130.F90 =================================================================== --- flang/test/Preprocessing/pp130.F90 +++ flang/test/Preprocessing/pp130.F90 @@ -1,4 +1,4 @@ -! RUN: not %flang -E %s 2>&1 | FileCheck %s +! RUN: not %flang -E -fdebug-dump-cooked-chars %s 2>&1 | FileCheck %s ! CHECK: error: bad character ('&') in Fortran token ! #define KWM &, use for continuation w/o pasting (ifort and nag seem to continue #define) #define KWM & Index: flang/tools/f18-parse-demo/f18-parse-demo.cpp =================================================================== --- flang/tools/f18-parse-demo/f18-parse-demo.cpp +++ flang/tools/f18-parse-demo/f18-parse-demo.cpp @@ -87,6 +87,7 @@ 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}; @@ -176,6 +177,11 @@ parsing.DumpProvenance(llvm::outs()); return {}; } + if (options.prescanAndReformat) { + parsing.messages().Emit(llvm::errs(), allCookedSources); + parsing.EmitPreprocessedSource(llvm::outs(), driver.lineDirectives); + return {}; + } if (driver.dumpCookedChars) { parsing.DumpCookedChars(llvm::outs()); return {}; @@ -353,7 +359,11 @@ driver.warningsAreErrors = true; } else if (arg == "-ed") { options.features.Enable(Fortran::common::LanguageFeature::OldDebugLines); - } else if (arg == "-E" || arg == "-fpreprocess-only") { + } else if (arg == "-E") { + options.prescanAndReformat = true; + } else if (arg == "-P") { + driver.lineDirectives = false; + } else if (arg == "-fdebug-dump-cooked-chars") { driver.dumpCookedChars = true; } else if (arg == "-fbackslash") { options.features.Enable( Index: flang/tools/f18/f18.cpp =================================================================== --- flang/tools/f18/f18.cpp +++ flang/tools/f18/f18.cpp @@ -93,6 +93,7 @@ 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}; @@ -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.dumpCookedChars) { + parsing.DumpCookedChars(llvm::outs()); + } else { + parsing.EmitPreprocessedSource(llvm::outs(), driver.lineDirectives); + } return {}; } parsing.Parse(llvm::outs()); @@ -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 -fdebug-dump-cooked-chars output of fixed-form + // cooked character stream options.fixedFormColumns = 1000000; } else if (arg == "-Mbackslash") { options.features.Enable( @@ -536,6 +542,10 @@ } else if (arg == "-ed") { options.features.Enable(Fortran::common::LanguageFeature::OldDebugLines); } else if (arg == "-E") { + options.prescanAndReformat = true; + } else if (arg == "-P") { + driver.lineDirectives = false; + } else if (arg == "-fdebug-dump-cooked-chars") { driver.dumpCookedChars = true; } else if (arg == "-fbackslash" || arg == "-fno-backslash") { options.features.Enable( Index: flang/unittests/Frontend/FrontendActionTest.cpp =================================================================== --- flang/unittests/Frontend/FrontendActionTest.cpp +++ 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().frontendOpts().set_dumpCookedChars(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).