[flang-commits] [flang] 96d229c - [flang][driver] Add options for unparsing
Andrzej Warzynski via flang-commits
flang-commits at lists.llvm.org
Tue Feb 16 01:33:12 PST 2021
Author: Andrzej Warzynski
Date: 2021-02-16T09:32:51Z
New Revision: 96d229c9abdfb2836e18a554bfb63b5d52aeebfa
URL: https://github.com/llvm/llvm-project/commit/96d229c9abdfb2836e18a554bfb63b5d52aeebfa
DIFF: https://github.com/llvm/llvm-project/commit/96d229c9abdfb2836e18a554bfb63b5d52aeebfa.diff
LOG: [flang][driver] Add options for unparsing
This patch adds the following compiler frontend driver options:
* -fdebug-unparse (f18 spelling: -funparse)
* -fdebug-unparse-with-symbols (f18 spelling: -funparse-with-symbols)
The new driver will only accept the new spelling. `f18` will accept both
the original and the new spelling.
A new base class for frontend actions is added: `PrescanAndSemaAction`.
This is added to reduce code duplication that otherwise these new
options would lead to. Implementation from
* `ParseSyntaxOnlyAction::ExecutionAction`
is moved to:
* `PrescanAndSemaAction::BeginSourceFileAction`
This implementation is now shared between:
* PrescanAndSemaAction
* ParseSyntaxOnlyAction
* DebugUnparseAction
* DebugUnparseWithSymbolsAction
All tests that don't require other yet unimplemented options are
updated. This way `flang-new -fc1` is used instead of `f18` when
`FLANG_BUILD_NEW_DRIVER` is set to `On`. In order to facilitate this,
`%flang_fc1` is added in the LIT configuration (lit.cfg.py).
`asFortran` from f18.cpp is duplicated as `getBasicAsFortran` in
FrontendOptions.cpp. At this stage it's hard to find a good place to
share this method. I suggest that we revisit this once a switch from
`f18` to `flang-new` is complete.
Differential Revision: https://reviews.llvm.org/D96483
Added:
Modified:
clang/include/clang/Driver/Options.td
flang/include/flang/Frontend/FrontendActions.h
flang/include/flang/Frontend/FrontendOptions.h
flang/lib/Frontend/CMakeLists.txt
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/lib/Frontend/FrontendOptions.cpp
flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
flang/lib/Parser/CMakeLists.txt
flang/test/Flang-Driver/driver-help.f90
flang/test/Parser/continuation-in-if.f
flang/test/Parser/pp-dir-comments.f90
flang/test/Semantics/canondo01.f90
flang/test/Semantics/canondo02.f90
flang/test/Semantics/canondo03.f90
flang/test/Semantics/canondo04.f90
flang/test/Semantics/canondo05.f90
flang/test/Semantics/critical04.f90
flang/test/Semantics/defined-ops.f90
flang/test/Semantics/doconcurrent02.f90
flang/test/Semantics/doconcurrent03.f90
flang/test/Semantics/doconcurrent04.f90
flang/test/Semantics/doconcurrent07.f90
flang/test/Semantics/label02.f90
flang/test/Semantics/label03.f90
flang/test/Semantics/label04.f90
flang/test/Semantics/label05.f90
flang/test/Semantics/label06.f90
flang/test/Semantics/label07.f90
flang/test/Semantics/label08.f90
flang/test/Semantics/label09.f90
flang/test/Semantics/label10.f90
flang/test/Semantics/label12.f90
flang/test/Semantics/label13.f90
flang/test/Semantics/label15.f90
flang/test/lit.cfg.py
flang/tools/f18/f18.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index d22956b86c4a..04a23c59e264 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4244,6 +4244,18 @@ def fopenacc : Flag<["-"], "fopenacc">, Group<f_Group>,
}
+//===----------------------------------------------------------------------===//
+// FC1 Options
+//===----------------------------------------------------------------------===//
+let Flags = [FC1Option, FlangOnlyOption] in {
+
+def fdebug_unparse : Flag<["-"], "fdebug-unparse">, Group<Action_Group>,
+ HelpText<"Unparse and stop.">;
+def fdebug_unparse_with_symbols : Flag<["-"], "fdebug-unparse-with-symbols">, Group<Action_Group>,
+ HelpText<"Unparse and stop.">;
+
+}
+
//===----------------------------------------------------------------------===//
// CC1 Options
//===----------------------------------------------------------------------===//
diff --git a/flang/include/flang/Frontend/FrontendActions.h b/flang/include/flang/Frontend/FrontendActions.h
index f28e3c2bc552..4c29d0d5a641 100644
--- a/flang/include/flang/Frontend/FrontendActions.h
+++ b/flang/include/flang/Frontend/FrontendActions.h
@@ -37,7 +37,23 @@ class PrintPreprocessedAction : public PrescanAction {
void ExecuteAction() override;
};
-class ParseSyntaxOnlyAction : public PrescanAction {
+//===----------------------------------------------------------------------===//
+// PrescanAndSema Actions
+//===----------------------------------------------------------------------===//
+class PrescanAndSemaAction : public FrontendAction {
+ void ExecuteAction() override = 0;
+ bool BeginSourceFileAction(CompilerInstance &ci) override;
+};
+
+class DebugUnparseWithSymbolsAction : public PrescanAndSemaAction {
+ void ExecuteAction() override;
+};
+
+class DebugUnparseAction : public PrescanAndSemaAction {
+ void ExecuteAction() override;
+};
+
+class ParseSyntaxOnlyAction : public PrescanAndSemaAction {
void ExecuteAction() override;
};
diff --git a/flang/include/flang/Frontend/FrontendOptions.h b/flang/include/flang/Frontend/FrontendOptions.h
index 1fc3a55091e1..0df8bdad5e83 100644
--- a/flang/include/flang/Frontend/FrontendOptions.h
+++ b/flang/include/flang/Frontend/FrontendOptions.h
@@ -9,6 +9,7 @@
#define LLVM_FLANG_FRONTEND_FRONTENDOPTIONS_H
#include "flang/Common/Fortran-features.h"
+#include "flang/Parser/unparse.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -32,6 +33,13 @@ enum ActionKind {
/// Emit a .o file.
EmitObj,
+ /// Parse, unparse the parse-tree and output a Fortran source file
+ DebugUnparse,
+
+ /// Parse, resolve the sybmols, unparse the parse-tree and then output a
+ /// Fortran source file
+ DebugUnparseWithSymbols,
+
/// TODO: RunPreprocessor, EmitLLVM, EmitLLVMOnly,
/// EmitCodeGenOnly, EmitAssembly, (...)
};
@@ -40,6 +48,10 @@ enum ActionKind {
/// \return True if the file extension should be processed as fixed form
bool isFixedFormSuffix(llvm::StringRef suffix);
+// TODO: Find a more suitable location for this. Added for compability with
+// f18.cpp (this is equivalent to `asFortran` defined there).
+Fortran::parser::AnalyzedObjectsAsFortran getBasicAsFortran();
+
/// \param suffix The file extension
/// \return True if the file extension should be processed as free form
bool isFreeFormSuffix(llvm::StringRef suffix);
diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt
index 095271f567f4..2ef38c557ce5 100644
--- a/flang/lib/Frontend/CMakeLists.txt
+++ b/flang/lib/Frontend/CMakeLists.txt
@@ -14,6 +14,7 @@ add_flang_library(flangFrontend
LINK_LIBS
FortranParser
FortranSemantics
+ FortranEvaluate
FortranCommon
clangBasic
clangDriver
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 23cbc21cedfd..8cec2affe483 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -110,6 +110,12 @@ static InputKind ParseFrontendArgs(FrontendOptions &opts,
case clang::driver::options::OPT_emit_obj:
opts.programAction_ = EmitObj;
break;
+ case clang::driver::options::OPT_fdebug_unparse:
+ opts.programAction_ = DebugUnparse;
+ break;
+ case clang::driver::options::OPT_fdebug_unparse_with_symbols:
+ opts.programAction_ = DebugUnparseWithSymbols;
+ break;
// TODO:
// case calng::driver::options::OPT_emit_llvm:
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 1a26e19bfe98..dc9da4eb7ba2 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -9,10 +9,13 @@
#include "flang/Frontend/FrontendActions.h"
#include "flang/Common/default-kinds.h"
#include "flang/Frontend/CompilerInstance.h"
+#include "flang/Frontend/FrontendOptions.h"
#include "flang/Parser/parsing.h"
#include "flang/Parser/provenance.h"
#include "flang/Parser/source.h"
+#include "flang/Parser/unparse.h"
#include "flang/Semantics/semantics.h"
+#include "flang/Semantics/unparse-with-symbols.h"
using namespace Fortran::frontend;
@@ -49,6 +52,75 @@ bool PrescanAction::BeginSourceFileAction(CompilerInstance &c1) {
return true;
}
+bool PrescanAndSemaAction::BeginSourceFileAction(CompilerInstance &c1) {
+ CompilerInstance &ci = this->instance();
+
+ std::string currentInputPath{GetCurrentFileOrBufferName()};
+
+ Fortran::parser::Options parserOptions = ci.invocation().fortranOpts();
+
+ if (ci.invocation().frontendOpts().fortranForm_ == FortranForm::Unknown) {
+ // Switch between fixed and free form format based on the input file
+ // extension.
+ //
+ // Ideally we should have all Fortran options set before entering this
+ // method (i.e. before processing any specific input files). However, we
+ // can't decide between fixed and free form based on the file extension
+ // earlier than this.
+ parserOptions.isFixedForm = currentInput().IsFixedForm();
+ }
+
+ // Prescan. In case of failure, report and return.
+ ci.parsing().Prescan(currentInputPath, parserOptions);
+
+ if (ci.parsing().messages().AnyFatalError()) {
+ const unsigned diagID = ci.diagnostics().getCustomDiagID(
+ clang::DiagnosticsEngine::Error, "Could not scan %0");
+ ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
+ ci.parsing().messages().Emit(llvm::errs(), ci.allCookedSources());
+
+ return false;
+ }
+
+ // Parse. In case of failure, report and return.
+ ci.parsing().Parse(llvm::outs());
+
+ if (ci.parsing().messages().AnyFatalError()) {
+ unsigned diagID = ci.diagnostics().getCustomDiagID(
+ clang::DiagnosticsEngine::Error, "Could not parse %0");
+ ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
+
+ ci.parsing().messages().Emit(
+ llvm::errs(), this->instance().allCookedSources());
+ return false;
+ }
+
+ // Report the diagnostics from parsing
+ ci.parsing().messages().Emit(llvm::errs(), ci.allCookedSources());
+
+ auto &parseTree{*ci.parsing().parseTree()};
+
+ // Prepare semantics
+ Fortran::semantics::Semantics semantics{ci.invocation().semanticsContext(),
+ parseTree, ci.parsing().cooked().AsCharBlock()};
+
+ // Run semantic checks
+ semantics.Perform();
+
+ // Report the diagnostics from the semantic checks
+ semantics.EmitMessages(ci.semaOutputStream());
+
+ if (semantics.AnyFatalError()) {
+ unsigned DiagID = ci.diagnostics().getCustomDiagID(
+ clang::DiagnosticsEngine::Error, "Semantic errors in %0");
+ ci.diagnostics().Report(DiagID) << GetCurrentFileOrBufferName();
+
+ return false;
+ }
+
+ return true;
+}
+
void InputOutputTestAction::ExecuteAction() {
CompilerInstance &ci = instance();
@@ -111,42 +183,25 @@ void PrintPreprocessedAction::ExecuteAction() {
}
}
-void ParseSyntaxOnlyAction::ExecuteAction() {
- CompilerInstance &ci = this->instance();
-
- // Parse. In case of failure, report and return.
- ci.parsing().Parse(llvm::outs());
-
- if (ci.parsing().messages().AnyFatalError()) {
- unsigned diagID = ci.diagnostics().getCustomDiagID(
- clang::DiagnosticsEngine::Error, "Could not parse %0");
- ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
-
- ci.parsing().messages().Emit(
- llvm::errs(), this->instance().allCookedSources());
- return;
- }
+void ParseSyntaxOnlyAction::ExecuteAction() {}
- // Report the diagnostics from parsing
- ci.parsing().messages().Emit(llvm::errs(), ci.allCookedSources());
-
- auto &parseTree{*ci.parsing().parseTree()};
+void DebugUnparseAction::ExecuteAction() {
+ auto &parseTree{instance().parsing().parseTree()};
+ Fortran::parser::AnalyzedObjectsAsFortran asFortran =
+ Fortran::frontend::getBasicAsFortran();
- // Prepare semantics
- Fortran::semantics::Semantics semantics{ci.invocation().semanticsContext(),
- parseTree, ci.parsing().cooked().AsCharBlock()};
-
- // Run semantic checks
- semantics.Perform();
+ // TODO: Options should come from CompilerInvocation
+ Unparse(llvm::outs(), *parseTree,
+ /*encoding=*/Fortran::parser::Encoding::UTF_8,
+ /*capitalizeKeywords=*/true, /*backslashEscapes=*/false,
+ /*preStatement=*/nullptr, &asFortran);
+}
- // Report the diagnostics from the semantic checks
- semantics.EmitMessages(ci.semaOutputStream());
+void DebugUnparseWithSymbolsAction::ExecuteAction() {
+ auto &parseTree{*instance().parsing().parseTree()};
- if (semantics.AnyFatalError()) {
- unsigned DiagID = ci.diagnostics().getCustomDiagID(
- clang::DiagnosticsEngine::Error, "Semantic errors in %0");
- ci.diagnostics().Report(DiagID) << GetCurrentFileOrBufferName();
- }
+ Fortran::semantics::UnparseWithSymbols(
+ llvm::outs(), parseTree, /*encoding=*/Fortran::parser::Encoding::UTF_8);
}
void EmitObjAction::ExecuteAction() {
diff --git a/flang/lib/Frontend/FrontendOptions.cpp b/flang/lib/Frontend/FrontendOptions.cpp
index 1f2668fd1e85..a43cac3bb1cb 100644
--- a/flang/lib/Frontend/FrontendOptions.cpp
+++ b/flang/lib/Frontend/FrontendOptions.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang/Frontend/FrontendOptions.h"
+#include "flang/Evaluate/expression.h"
using namespace Fortran::frontend;
@@ -25,6 +26,34 @@ bool Fortran::frontend::isFreeFormSuffix(llvm::StringRef suffix) {
suffix == "f08" || suffix == "F08" || suffix == "f18" || suffix == "F18";
}
+// TODO: This is a copy of `asFortran` from f18.cpp and is added here for
+// compatiblity. It doesn't really belong here, but I couldn't find a better
+// place. We should decide whether to add it to the Evaluate or Parse/Unparse
+// APIs or some dedicated utility library in the driver.
+Fortran::parser::AnalyzedObjectsAsFortran
+Fortran::frontend::getBasicAsFortran() {
+ return Fortran::parser::AnalyzedObjectsAsFortran{
+ [](llvm::raw_ostream &o, const Fortran::evaluate::GenericExprWrapper &x) {
+ if (x.v) {
+ x.v->AsFortran(o);
+ } else {
+ o << "(bad expression)";
+ }
+ },
+ [](llvm::raw_ostream &o,
+ const Fortran::evaluate::GenericAssignmentWrapper &x) {
+ if (x.v) {
+ x.v->AsFortran(o);
+ } else {
+ o << "(bad assignment)";
+ }
+ },
+ [](llvm::raw_ostream &o, const Fortran::evaluate::ProcedureRef &x) {
+ x.AsFortran(o << "CALL ");
+ },
+ };
+}
+
InputKind FrontendOptions::GetInputKindForExtension(llvm::StringRef extension) {
if (isFixedFormSuffix(extension) || isFreeFormSuffix(extension)) {
return Language::Fortran;
diff --git a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 50c9fca0b882..12f538c929fd 100644
--- a/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -37,6 +37,12 @@ static std::unique_ptr<FrontendAction> CreateFrontendBaseAction(
case EmitObj:
return std::make_unique<EmitObjAction>();
break;
+ case DebugUnparse:
+ return std::make_unique<DebugUnparseAction>();
+ break;
+ case DebugUnparseWithSymbols:
+ return std::make_unique<DebugUnparseWithSymbolsAction>();
+ break;
default:
break;
// TODO:
diff --git a/flang/lib/Parser/CMakeLists.txt b/flang/lib/Parser/CMakeLists.txt
index 9ee416803177..600a2f67df44 100644
--- a/flang/lib/Parser/CMakeLists.txt
+++ b/flang/lib/Parser/CMakeLists.txt
@@ -1,4 +1,3 @@
-
add_flang_library(FortranParser
Fortran-parsers.cpp
char-buffer.cpp
diff --git a/flang/test/Flang-Driver/driver-help.f90 b/flang/test/Flang-Driver/driver-help.f90
index 55a989f2faab..7d2bf00614e6 100644
--- a/flang/test/Flang-Driver/driver-help.f90
+++ b/flang/test/Flang-Driver/driver-help.f90
@@ -46,6 +46,9 @@
! HELP-FC1-NEXT: -D <macro>=<value> Define <macro> to <value> (or 1 if <value> omitted)
! HELP-FC1-NEXT: -emit-obj Emit native object files
! HELP-FC1-NEXT: -E Only run the preprocessor
+! HELP-FC1-NEXT: -fdebug-unparse-with-symbols
+! HELP-FC1-NEXT: Unparse and stop.
+! HELP-FC1-NEXT: -fdebug-unparse Unparse and stop.
! HELP-FC1-NEXT: -ffixed-form Process source files in fixed form
! HELP-FC1-NEXT: -ffixed-line-length=<value>
! HELP-FC1-NEXT: Use <value> as character line width in fixed mode
diff --git a/flang/test/Parser/continuation-in-if.f b/flang/test/Parser/continuation-in-if.f
index 928170eb6cd5..684e9188b716 100644
--- a/flang/test/Parser/continuation-in-if.f
+++ b/flang/test/Parser/continuation-in-if.f
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
! CHECK: CALL foo("N","N")
#ifdef transpose
call foo('T',
diff --git a/flang/test/Parser/pp-dir-comments.f90 b/flang/test/Parser/pp-dir-comments.f90
index f5fe4ca5c71e..14d2552e9045 100644
--- a/flang/test/Parser/pp-dir-comments.f90
+++ b/flang/test/Parser/pp-dir-comments.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
#define pmk
#ifdef pmk // comment
diff --git a/flang/test/Semantics/canondo01.f90 b/flang/test/Semantics/canondo01.f90
index 3379953b12d7..50ffa489019e 100644
--- a/flang/test/Semantics/canondo01.f90
+++ b/flang/test/Semantics/canondo01.f90
@@ -1,5 +1,5 @@
-! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: end do
SUBROUTINE sub00(a,b,n,m)
diff --git a/flang/test/Semantics/canondo02.f90 b/flang/test/Semantics/canondo02.f90
index 69745c4ef458..1a2252ab4546 100644
--- a/flang/test/Semantics/canondo02.f90
+++ b/flang/test/Semantics/canondo02.f90
@@ -1,5 +1,5 @@
-! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: end do
SUBROUTINE sub00(a,b,n,m)
diff --git a/flang/test/Semantics/canondo03.f90 b/flang/test/Semantics/canondo03.f90
index 55b3fd2fe8f1..516840b40d09 100644
--- a/flang/test/Semantics/canondo03.f90
+++ b/flang/test/Semantics/canondo03.f90
@@ -1,5 +1,5 @@
-! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: 10 continue
! CHECK: end do
diff --git a/flang/test/Semantics/canondo04.f90 b/flang/test/Semantics/canondo04.f90
index b252c9820159..ea955230b5ad 100644
--- a/flang/test/Semantics/canondo04.f90
+++ b/flang/test/Semantics/canondo04.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK-NOT: do [1-9]
! Figure out how to also execute this test.
diff --git a/flang/test/Semantics/canondo05.f90 b/flang/test/Semantics/canondo05.f90
index 788dc7a5de89..0de34f18fb7c 100644
--- a/flang/test/Semantics/canondo05.f90
+++ b/flang/test/Semantics/canondo05.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! RUN: %f18 -fopenmp -funparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK-NOT: do *[1-9]
diff --git a/flang/test/Semantics/critical04.f90 b/flang/test/Semantics/critical04.f90
index 4d08597fb7cd..82db87411ed4 100644
--- a/flang/test/Semantics/critical04.f90
+++ b/flang/test/Semantics/critical04.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK-NOT: Control flow escapes from CRITICAL
subroutine test1(a, i)
diff --git a/flang/test/Semantics/defined-ops.f90 b/flang/test/Semantics/defined-ops.f90
index 24e72677c6eb..e46caeb82b94 100644
--- a/flang/test/Semantics/defined-ops.f90
+++ b/flang/test/Semantics/defined-ops.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
! Check the analyzed form of a defined operator or assignment.
diff --git a/flang/test/Semantics/doconcurrent02.f90 b/flang/test/Semantics/doconcurrent02.f90
index 2720e1356db1..2473b3ee0b74 100644
--- a/flang/test/Semantics/doconcurrent02.f90
+++ b/flang/test/Semantics/doconcurrent02.f90
@@ -1,6 +1,6 @@
! when the loops are not DO CONCURRENT
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK-NOT: image control statement not allowed in DO CONCURRENT
! CHECK-NOT: RETURN not allowed in DO CONCURRENT
! CHECK-NOT: call to impure procedure in DO CONCURRENT not allowed
diff --git a/flang/test/Semantics/doconcurrent03.f90 b/flang/test/Semantics/doconcurrent03.f90
index d98db8dd60c8..45cbcc7a5737 100644
--- a/flang/test/Semantics/doconcurrent03.f90
+++ b/flang/test/Semantics/doconcurrent03.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: Control flow escapes from DO CONCURRENT
! CHECK: branch into loop body from outside
! CHECK: the loop branched into
diff --git a/flang/test/Semantics/doconcurrent04.f90 b/flang/test/Semantics/doconcurrent04.f90
index 079c8d423503..c3a9779235d6 100644
--- a/flang/test/Semantics/doconcurrent04.f90
+++ b/flang/test/Semantics/doconcurrent04.f90
@@ -1,5 +1,5 @@
! C1122 The index-name shall be a named scalar variable of type integer.
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: Must have INTEGER type, but is REAL(4)
subroutine do_concurrent_test1(n)
diff --git a/flang/test/Semantics/doconcurrent07.f90 b/flang/test/Semantics/doconcurrent07.f90
index d9c494efe0ab..982608591f42 100644
--- a/flang/test/Semantics/doconcurrent07.f90
+++ b/flang/test/Semantics/doconcurrent07.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK-NOT: exit from DO CONCURRENT construct
subroutine do_concurrent_test1(n)
diff --git a/flang/test/Semantics/label02.f90 b/flang/test/Semantics/label02.f90
index fa4f37ec3a44..32fe2c21a93e 100644
--- a/flang/test/Semantics/label02.f90
+++ b/flang/test/Semantics/label02.f90
@@ -1,5 +1,5 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: Label '0' is out of range
! CHECK: Label '100000' is out of range
! CHECK: Label '123456' is out of range
diff --git a/flang/test/Semantics/label03.f90 b/flang/test/Semantics/label03.f90
index ecc21f92b93e..9e7485f38307 100644
--- a/flang/test/Semantics/label03.f90
+++ b/flang/test/Semantics/label03.f90
@@ -1,5 +1,5 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: DO loop doesn't properly nest
! CHECK: DO loop conflicts
! CHECK: Label '30' cannot be found
diff --git a/flang/test/Semantics/label04.f90 b/flang/test/Semantics/label04.f90
index ea496fb95789..c5294115b0eb 100644
--- a/flang/test/Semantics/label04.f90
+++ b/flang/test/Semantics/label04.f90
@@ -1,5 +1,5 @@
-! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: branch into loop body from outside
! CHECK: do 10 i = 1, m
! CHECK: the loop branched into
diff --git a/flang/test/Semantics/label05.f90 b/flang/test/Semantics/label05.f90
index fbcdb4f22cb9..958627acf4b5 100644
--- a/flang/test/Semantics/label05.f90
+++ b/flang/test/Semantics/label05.f90
@@ -1,5 +1,5 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: Label '50' was not found
! CHECK: Label '55' is not in scope
! CHECK: Label '70' is not a branch target
diff --git a/flang/test/Semantics/label06.f90 b/flang/test/Semantics/label06.f90
index 16be4df30cb0..fab521c42ecd 100644
--- a/flang/test/Semantics/label06.f90
+++ b/flang/test/Semantics/label06.f90
@@ -1,5 +1,5 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: Label '10' is not in scope
! CHECK: Label '20' was not found
! CHECK: Label '30' is not a branch target
diff --git a/flang/test/Semantics/label07.f90 b/flang/test/Semantics/label07.f90
index a01b58e16d32..55e2b268933c 100644
--- a/flang/test/Semantics/label07.f90
+++ b/flang/test/Semantics/label07.f90
@@ -1,5 +1,5 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: Label '30' is not a branch target
! CHECK: Control flow use of '30'
! CHECK: Label '10' is not in scope
diff --git a/flang/test/Semantics/label08.f90 b/flang/test/Semantics/label08.f90
index 57858022a526..4ccf6e612380 100644
--- a/flang/test/Semantics/label08.f90
+++ b/flang/test/Semantics/label08.f90
@@ -1,5 +1,5 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: CYCLE construct-name is not in scope
! CHECK: IF construct name unexpected
! CHECK: unnamed IF statement
diff --git a/flang/test/Semantics/label09.f90 b/flang/test/Semantics/label09.f90
index 27644b671471..d34022ebffaf 100644
--- a/flang/test/Semantics/label09.f90
+++ b/flang/test/Semantics/label09.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: Label '60' was not found
subroutine s(a)
diff --git a/flang/test/Semantics/label10.f90 b/flang/test/Semantics/label10.f90
index ad234ccb4bbb..09bb3ab1e9ac 100644
--- a/flang/test/Semantics/label10.f90
+++ b/flang/test/Semantics/label10.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: '60' not a FORMAT
! CHECK: data transfer use of '60'
diff --git a/flang/test/Semantics/label12.f90 b/flang/test/Semantics/label12.f90
index c917a116e31e..1a926de7f07f 100644
--- a/flang/test/Semantics/label12.f90
+++ b/flang/test/Semantics/label12.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: expected end of statement
subroutine s
diff --git a/flang/test/Semantics/label13.f90 b/flang/test/Semantics/label13.f90
index f03156aa1775..8c5a901e2800 100644
--- a/flang/test/Semantics/label13.f90
+++ b/flang/test/Semantics/label13.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
! CHECK: branch into loop body from outside
! CHECK: the loop branched into
diff --git a/flang/test/Semantics/label15.f90 b/flang/test/Semantics/label15.f90
index a26a68c001dd..58b9184b8937 100644
--- a/flang/test/Semantics/label15.f90
+++ b/flang/test/Semantics/label15.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
!CHECK-NOT: error:
module mm
diff --git a/flang/test/lit.cfg.py b/flang/test/lit.cfg.py
index d724628dc0bb..76f9c0b9ad3f 100644
--- a/flang/test/lit.cfg.py
+++ b/flang/test/lit.cfg.py
@@ -74,10 +74,15 @@
if config.include_flang_new_driver_test:
tools.append(ToolSubst('%flang-new', command=FindTool('flang-new'), unresolved='fatal'))
tools.append(ToolSubst('%flang', command=FindTool('flang-new'), unresolved='fatal'))
+ tools.append(ToolSubst('%flang_fc1', command=FindTool('flang-new'),
+ extra_args=['-fc1'], unresolved='fatal'))
else:
tools.append(ToolSubst('%flang', command=FindTool('f18'),
extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
unresolved='fatal'))
+ tools.append(ToolSubst('%flang_fc1', command=FindTool('f18'),
+ extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
+ unresolved='fatal'))
if config.flang_standalone_build:
llvm_config.add_tool_substitutions(tools, [config.flang_llvm_tools_dir])
diff --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp
index 7960403726d5..15d42821f1a1 100644
--- a/flang/tools/f18/f18.cpp
+++ b/flang/tools/f18/f18.cpp
@@ -540,9 +540,10 @@ int main(int argc, char *const argv[]) {
options.instrumentedParse = true;
} else if (arg == "-fdebug-no-semantics") {
driver.debugNoSemantics = true;
- } else if (arg == "-funparse") {
+ } else if (arg == "-funparse" || arg == "-fdebug-unparse") {
driver.dumpUnparse = true;
- } else if (arg == "-funparse-with-symbols") {
+ } else if (arg == "-funparse-with-symbols" ||
+ arg == "-fdebug-unparse-with-symbols") {
driver.dumpUnparseWithSymbols = true;
} else if (arg == "-funparse-typed-exprs-to-f18-fc") {
driver.unparseTypedExprsToF18_FC = true;
More information about the flang-commits
mailing list