summaryrefslogtreecommitdiff
path: root/flang/lib/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Frontend')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp5
-rw-r--r--flang/lib/Frontend/FrontendAction.cpp13
-rw-r--r--flang/lib/Frontend/FrontendActions.cpp8
3 files changed, 23 insertions, 3 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 79386c92d552..340efb1c63a5 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -766,6 +766,11 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
opts.features.Enable(Fortran::common::LanguageFeature::DefaultSave);
}
+ // -fsave-main-program
+ if (args.hasArg(clang::driver::options::OPT_fsave_main_program)) {
+ opts.features.Enable(Fortran::common::LanguageFeature::SaveMainProgram);
+ }
+
if (args.hasArg(
clang::driver::options::OPT_falternative_parameter_statement)) {
opts.features.Enable(Fortran::common::LanguageFeature::OldStyleParameter);
diff --git a/flang/lib/Frontend/FrontendAction.cpp b/flang/lib/Frontend/FrontendAction.cpp
index 041182bdf617..9a555bc7cd23 100644
--- a/flang/lib/Frontend/FrontendAction.cpp
+++ b/flang/lib/Frontend/FrontendAction.cpp
@@ -232,6 +232,19 @@ bool FrontendAction::reportFatalErrors(const char (&message)[N]) {
instance->getAllCookedSources());
return true;
}
+ if (instance->getParsing().parseTree().has_value() &&
+ !instance->getParsing().consumedWholeFile()) {
+ // Parsing failed without error.
+ const unsigned diagID = instance->getDiagnostics().getCustomDiagID(
+ clang::DiagnosticsEngine::Error, message);
+ instance->getDiagnostics().Report(diagID) << getCurrentFileOrBufferName();
+ instance->getParsing().messages().Emit(llvm::errs(),
+ instance->getAllCookedSources());
+ instance->getParsing().EmitMessage(
+ llvm::errs(), instance->getParsing().finalRestingPlace(),
+ "parser FAIL (final position)", "error: ", llvm::raw_ostream::RED);
+ return true;
+ }
return false;
}
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 603cb039d20b..310cd650349c 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -566,9 +566,11 @@ void DebugMeasureParseTreeAction::executeAction() {
// Parse. In case of failure, report and return.
ci.getParsing().Parse(llvm::outs());
- if (!ci.getParsing().messages().empty() &&
- (ci.getInvocation().getWarnAsErr() ||
- ci.getParsing().messages().AnyFatalError())) {
+ if ((ci.getParsing().parseTree().has_value() &&
+ !ci.getParsing().consumedWholeFile()) ||
+ (!ci.getParsing().messages().empty() &&
+ (ci.getInvocation().getWarnAsErr() ||
+ ci.getParsing().messages().AnyFatalError()))) {
unsigned diagID = ci.getDiagnostics().getCustomDiagID(
clang::DiagnosticsEngine::Error, "Could not parse %0");
ci.getDiagnostics().Report(diagID) << getCurrentFileOrBufferName();