aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaris Rehman <faris.rehman@arm.com>2021-01-27 09:45:56 +0000
committerFaris Rehman <faris.rehman@arm.com>2021-01-27 10:27:21 +0000
commita8f51ea2120bc454e3e3ece6995febe47fbb98d1 (patch)
tree00f819a1669536503c201996bfde6970e76accd8
parentda83b869ab06dd177a08cad7b0d98f42aa4bb941 (diff)
downloadllvm-a8f51ea2120bc454e3e3ece6995febe47fbb98d1.zip
llvm-a8f51ea2120bc454e3e3ece6995febe47fbb98d1.tar.gz
llvm-a8f51ea2120bc454e3e3ece6995febe47fbb98d1.tar.bz2
[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
-rw-r--r--flang/lib/Frontend/FrontendActions.cpp3
-rw-r--r--flang/test/Frontend/preprocessor-diag.f9011
-rw-r--r--flang/test/Frontend/prescanner-diag.f9017
3 files changed, 20 insertions, 11 deletions
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index ee6f71c..c200d60 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -94,6 +94,9 @@ void ParseSyntaxOnlyAction::ExecuteAction() {
return;
}
+ // Report the diagnostics from parsing
+ ci.parsing().messages().Emit(llvm::errs(), ci.allCookedSources());
+
auto &parseTree{*ci.parsing().parseTree()};
// Prepare semantics
diff --git a/flang/test/Frontend/preprocessor-diag.f90 b/flang/test/Frontend/preprocessor-diag.f90
deleted file mode 100644
index 2a16aa4..0000000
--- a/flang/test/Frontend/preprocessor-diag.f90
+++ /dev/null
@@ -1,11 +0,0 @@
-! 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
diff --git a/flang/test/Frontend/prescanner-diag.f90 b/flang/test/Frontend/prescanner-diag.f90
new file mode 100644
index 0000000..4c7e6e3
--- /dev/null
+++ b/flang/test/Frontend/prescanner-diag.f90
@@ -0,0 +1,17 @@
+! Test that the driver correctly reports diagnostics from the prescanner. The contents of the include file are irrelevant here.
+
+! Test with -E (i.e. PrintPreprocessedAction, stops after prescanning)
+! 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 with -fsyntax-only (i.e. ParseSyntaxOnlyAction, stops after semantic checks)
+! RUN: %f18 -fparse-only -I %S/Inputs/ %s 2>&1 | FileCheck %s
+! RUN: %flang-new -fsyntax-only -I %S/Inputs/ %s 2>&1 | FileCheck %s
+! RUN: %flang-new -fc1 -fsyntax-only -I %S/Inputs/ %s 2>&1 | FileCheck %s
+
+! CHECK: prescanner-diag.f90:14:20: #include: extra stuff ignored after file name
+#include <empty.h> comment
+! CHECK: prescanner-diag.f90:16:20: #include: extra stuff ignored after file name
+#include "empty.h" comment
+end