Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions flang/lib/Frontend/FrontendAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 5 additions & 3 deletions flang/lib/Frontend/FrontendActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Integration/debug-local-var-2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ function fn2(a2, b2, c2) result (res2)
end function
end program

LINEONLY-NOT: DILocalVariable
! LINEONLY-NOT: DILocalVariable
4 changes: 3 additions & 1 deletion flang/test/Parser/at-process.f
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
! RUN: %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s
! RUN: not %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s

! Test ignoring @PROCESS directive in fixed source form

Expand All @@ -18,3 +18,5 @@ subroutine f()

!CHECK: Character in fixed-form label field must be a digit
@precoss

!CHECK: at-process.f:14:1: error: parser FAIL (final position)
5 changes: 5 additions & 0 deletions flang/test/Parser/unparseable.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
! RUN: not %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s
! CHECK: unparseable.f90:5:1: error: parser FAIL (final position)
module m
end
select type (barf)
Loading