[flang] Dump parse tree even if semantic error occurs
authorTim Keith <tkeith@nvidia.com>
Wed, 17 Apr 2019 14:44:58 +0000 (07:44 -0700)
committerTim Keith <tkeith@nvidia.com>
Wed, 17 Apr 2019 14:44:58 +0000 (07:44 -0700)
When -fdebug-dump-parse-tree is specified, dump the parse tree even
if semantic errors have occurred. This is necessary to see the parse
tree after it has been transformed.

Original-commit: flang-compiler/f18@bbdb0717da953c959cb1b6c531684952c239b98b
Reviewed-on: https://github.com/flang-compiler/f18/pull/417

flang/tools/f18/f18.cc

index 79802e65a8643729554e58aec67a21066ca27c6e..2b4a45309152ed3cc1cf522f0841cf88b4005070 100644 (file)
@@ -232,6 +232,9 @@ std::string CompileFortran(std::string path, Fortran::parser::Options options,
     if (semantics.AnyFatalError()) {
       std::cerr << driver.prefix << "semantic errors in " << path << '\n';
       exitStatus = EXIT_FAILURE;
+      if (driver.dumpParseTree) {
+        Fortran::parser::DumpTree(std::cout, parseTree);
+      }
       return {};
     }
     if (driver.dumpUnparseWithSymbols) {