[PATCH] D111308: [flang][driver] Add actions that execute despite semantic errors

Andrzej Warzynski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 11 04:53:46 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6f8ef1d6e879: [flang][driver] Add actions that execute despite semantic errors (authored by awarzynski).

Changed prior to commit:
  https://reviews.llvm.org/D111308?vs=378141&id=378625#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111308/new/

https://reviews.llvm.org/D111308

Files:
  flang/include/flang/Frontend/FrontendActions.h
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/dump-all-bad.f90


Index: flang/test/Driver/dump-all-bad.f90
===================================================================
--- /dev/null
+++ flang/test/Driver/dump-all-bad.f90
@@ -0,0 +1,21 @@
+! Verify that -fdebug-dump-all dumps both symbols and the parse tree, even when semantic errors are present
+
+!----------
+! RUN lines
+!----------
+! RUN: not %flang_fc1 -fdebug-dump-all %s 2>&1 | FileCheck %s
+
+!----------------
+! EXPECTED OUTPUT
+!----------------
+! CHECK: error: Semantic errors in
+! CHECK: Flang: parse tree dump
+! CHECK: Flang: symbols dump
+
+!-------
+! INPUT
+!-------
+program bad
+  real,pointer :: x
+  x = null()      ! Error - must be pointer assignment
+end
Index: flang/lib/Frontend/FrontendActions.cpp
===================================================================
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -40,6 +40,11 @@
   return RunPrescan() && RunParse() && RunSemanticChecks();
 }
 
+bool PrescanAndSemaDebugAction::BeginSourceFileAction() {
+  // Semantic checks are made to succeed unconditionally.
+  return RunPrescan() && RunParse() && (RunSemanticChecks() || true);
+}
+
 //===----------------------------------------------------------------------===//
 // Custom ExecuteAction
 //===----------------------------------------------------------------------===//
Index: flang/include/flang/Frontend/FrontendActions.h
===================================================================
--- flang/include/flang/Frontend/FrontendActions.h
+++ flang/include/flang/Frontend/FrontendActions.h
@@ -84,6 +84,9 @@
 
 //===----------------------------------------------------------------------===//
 // PrescanAndSema Actions
+//
+// These actions will parse the input, run the semantic checks and execute
+// their actions provided that no parsing or semantic errors were found.
 //===----------------------------------------------------------------------===//
 class PrescanAndSemaAction : public FrontendAction {
 
@@ -107,10 +110,6 @@
   void ExecuteAction() override;
 };
 
-class DebugDumpAllAction : public PrescanAndSemaAction {
-  void ExecuteAction() override;
-};
-
 class DebugPreFIRTreeAction : public PrescanAndSemaAction {
   void ExecuteAction() override;
 };
@@ -131,6 +130,22 @@
   void ExecuteAction() override = 0;
 };
 
+//===----------------------------------------------------------------------===//
+// PrescanAndSemaDebug Actions
+//
+// These actions will parse the input, run the semantic checks and execute
+// their actions regardless of whether any semantic errors are found.
+//===----------------------------------------------------------------------===//
+class PrescanAndSemaDebugAction : public FrontendAction {
+
+  void ExecuteAction() override = 0;
+  bool BeginSourceFileAction() override;
+};
+
+class DebugDumpAllAction : public PrescanAndSemaDebugAction {
+  void ExecuteAction() override;
+};
+
 } // namespace Fortran::frontend
 
 #endif // LLVM_FLANG_FRONTEND_FRONTENDACTIONS_H


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111308.378625.patch
Type: text/x-patch
Size: 2995 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211011/ab5ce21b/attachment.bin>


More information about the llvm-commits mailing list