Skip to content

Commit a8f51ea

Browse files
author
Faris Rehman
committed
[flang][driver] Report prescanning diags during syntax-only parsing
Ensure diagnostics from the prescanner are reported when running `flang-new -fsyntax-only` (i.e. only syntax parsing). This keeps the diagnostics output of flang-new consistent with `f18 -fparse-only` when running the syntax parsing action, ParseSyntaxOnlyAction. Summary of changes: - Modify ParseSyntaxOnlyAction::ExecuteAction to report diagnostics Differential Revision: https://reviews.llvm.org/D95220
1 parent da83b86 commit a8f51ea

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

flang/lib/Frontend/FrontendActions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ void ParseSyntaxOnlyAction::ExecuteAction() {
9494
return;
9595
}
9696

97+
// Report the diagnostics from parsing
98+
ci.parsing().messages().Emit(llvm::errs(), ci.allCookedSources());
99+
97100
auto &parseTree{*ci.parsing().parseTree()};
98101

99102
// Prepare semantics

flang/test/Frontend/preprocessor-diag.f90

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
! Test that the driver correctly reports diagnostics from the prescanner. The contents of the include file are irrelevant here.
2+
3+
! Test with -E (i.e. PrintPreprocessedAction, stops after prescanning)
4+
! RUN: %f18 -E -I %S/Inputs/ %s 2>&1 | FileCheck %s
5+
! RUN: %flang-new -E -I %S/Inputs/ %s 2>&1 | FileCheck %s
6+
! RUN: %flang-new -fc1 -E -I %S/Inputs/ %s 2>&1 | FileCheck %s
7+
8+
! Test with -fsyntax-only (i.e. ParseSyntaxOnlyAction, stops after semantic checks)
9+
! RUN: %f18 -fparse-only -I %S/Inputs/ %s 2>&1 | FileCheck %s
10+
! RUN: %flang-new -fsyntax-only -I %S/Inputs/ %s 2>&1 | FileCheck %s
11+
! RUN: %flang-new -fc1 -fsyntax-only -I %S/Inputs/ %s 2>&1 | FileCheck %s
12+
13+
! CHECK: prescanner-diag.f90:14:20: #include: extra stuff ignored after file name
14+
#include <empty.h> comment
15+
! CHECK: prescanner-diag.f90:16:20: #include: extra stuff ignored after file name
16+
#include "empty.h" comment
17+
end

0 commit comments

Comments
 (0)