forked from OSchip/llvm-project
[flang][driver] Make the driver report diagnostics from the prescanner
This patch makes sure that diagnostics from the prescanner are reported when running `flang-new -E` (i.e. only the preprocessor phase is requested). More specifically, the `PrintPreprocessedAction` action is updated. With this patch we make sure that the `f18` and `flang-new` provide identical output when running the preprocessor and the prescanner generates diagnostics. Differential Revision: https://reviews.llvm.org/D94782
This commit is contained in:
parent
e4eaf9d820
commit
0eeb15741b
|
@ -61,6 +61,9 @@ void PrintPreprocessedAction::ExecuteAction() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print diagnostics from the preprocessor
|
||||||
|
ci.parsing().messages().Emit(llvm::errs(), ci.allCookedSources());
|
||||||
|
|
||||||
// Create a file and save the preprocessed output there
|
// Create a file and save the preprocessed output there
|
||||||
if (auto os{ci.CreateDefaultOutputFile(
|
if (auto os{ci.CreateDefaultOutputFile(
|
||||||
/*Binary=*/true, /*InFile=*/GetCurrentFileOrBufferName())}) {
|
/*Binary=*/true, /*InFile=*/GetCurrentFileOrBufferName())}) {
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
! RUN: %f18 -E -I %S/Inputs/ %s 2>&1 | FileCheck %s
|
||||||
|
! RUN: %flang-new -E -I %S/Inputs/ %s 2>&1 | FileCheck %s
|
||||||
|
! RUN: %flang-new -fc1 -E -I %S/Inputs/ %s 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
! Test that the driver correctly reports diagnostics from the prescanner. The contents of the include file are irrelevant here.
|
||||||
|
|
||||||
|
! CHECK: preprocessor-diag.f90:8:20: #include: extra stuff ignored after file name
|
||||||
|
#include <empty.h> comment
|
||||||
|
! CHECK: preprocessor-diag.f90:10:20: #include: extra stuff ignored after file name
|
||||||
|
#include "empty.h" comment
|
||||||
|
end
|
Loading…
Reference in New Issue