diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp --- a/flang/lib/Frontend/FrontendActions.cpp +++ b/flang/lib/Frontend/FrontendActions.cpp @@ -61,6 +61,9 @@ return; } + // Print diagnostics from the preprocessor + ci.parsing().messages().Emit(llvm::errs(), ci.allCookedSources()); + // Create a file and save the preprocessed output there if (auto os{ci.CreateDefaultOutputFile( /*Binary=*/true, /*InFile=*/GetCurrentFileOrBufferName())}) { diff --git a/flang/test/Frontend/Inputs/empty.h b/flang/test/Frontend/Inputs/empty.h new file mode 100644 diff --git a/flang/test/Frontend/preprocessor-diag.f90 b/flang/test/Frontend/preprocessor-diag.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Frontend/preprocessor-diag.f90 @@ -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 comment +! CHECK: preprocessor-diag.f90:10:20: #include: extra stuff ignored after file name +#include "empty.h" comment +end