[flang] Make unparsing of typed Exprs conditional when unparsing to pgf90
authorpeter klausler <pklausler@nvidia.com>
Tue, 25 Jun 2019 22:16:21 +0000 (15:16 -0700)
committerpeter klausler <pklausler@nvidia.com>
Fri, 28 Jun 2019 16:16:50 +0000 (09:16 -0700)
Original-commit: flang-compiler/f18@3b79c290cd4cb5299b931d4b6e051cb677cffab4
Reviewed-on: https://github.com/flang-compiler/f18/pull/531
Tree-same-pre-rewrite: false

flang/tools/f18/f18.cc

index 96c60cb..996bf58 100644 (file)
@@ -98,6 +98,7 @@ struct DriverOptions {
   bool debugResolveNames{false};
   bool debugSemantics{false};
   bool measureTree{false};
+  bool unparseTypedExprsToPGF90{false};
   std::vector<std::string> pgf90Args;
   const char *prefix{nullptr};
 };
@@ -274,7 +275,8 @@ std::string CompileFortran(std::string path, Fortran::parser::Options options,
     Unparse(tmpSource, parseTree, driver.encoding, true /*capitalize*/,
         options.features.IsEnabled(
             Fortran::parser::LanguageFeature::BackslashEscapes),
-        nullptr /* action before each statement */, &unparseExpression);
+        nullptr /* action before each statement */,
+        driver.unparseTypedExprsToPGF90 ? &unparseExpression : nullptr);
     Fortran::evaluate::formatForPGF90 = false;
   }
 
@@ -429,6 +431,8 @@ int main(int argc, char *const argv[]) {
       driver.dumpUnparse = true;
     } else if (arg == "-funparse-with-symbols") {
       driver.dumpUnparseWithSymbols = true;
+    } else if (arg == "-funparse-typed-exprs-to-pgf90") {
+      driver.unparseTypedExprsToPGF90 = true;
     } else if (arg == "-fparse-only") {
       driver.parseOnly = true;
     } else if (arg == "-c") {