From: peter klausler Date: Thu, 15 Mar 2018 23:03:28 +0000 (-0700) Subject: [flang] Unparsing fixes, PGF90 bug work-arounds. X-Git-Tag: llvmorg-12-init~9537^2~2854 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dcd094234cbcc68cfc2555a78d584f4f458e128c;p=platform%2Fupstream%2Fllvm.git [flang] Unparsing fixes, PGF90 bug work-arounds. Original-commit: flang-compiler/f18@c9c98c0e5cedc3e1c6f01b86d1d87c22c960dded Reviewed-on: https://github.com/flang-compiler/f18/pull/26 Tree-same-pre-rewrite: false --- diff --git a/flang/lib/parser/unparse.cc b/flang/lib/parser/unparse.cc index 78c045c..feb1148a 100644 --- a/flang/lib/parser/unparse.cc +++ b/flang/lib/parser/unparse.cc @@ -332,13 +332,13 @@ public: } bool Pre(const TypeBoundProcedureStmt::WithoutInterface &x) { // R749 Word("PROCEDURE"), Walk(", ", x.attributes, ", "); - Put(" :: "), Walk(x.declarations); + Put(" :: "), Walk(x.declarations, ", "); return false; } bool Pre(const TypeBoundProcedureStmt::WithInterface &x) { Word("PROCEDURE("), Walk(x.interfaceName), Put("), "); Walk(x.attributes); - Put(" :: "), Walk(x.bindingNames); + Put(" :: "), Walk(x.bindingNames, ", "); return false; } bool Pre(const TypeBoundProcDecl &x) { // R750 @@ -433,15 +433,13 @@ public: const auto &attrs = std::get>(x.t); const auto &decls = std::get>(x.t); Walk(dts), Walk(", ", attrs, ", "); - if (!attrs.empty() || - (!std::holds_alternative(dts.u) && - std::none_of(decls.begin(), decls.end(), [](const EntityDecl &d) { - const auto &init = std::get>(d.t); - return init.has_value() && - std::holds_alternative>>( - init->u); - }))) { - Put(" ::"); + if (!std::holds_alternative(dts.u) && + (!attrs.empty() || + !std::holds_alternative(dts.u) || + std::any_of(decls.begin(), decls.end(), [](const EntityDecl &d) { + return std::get>(d.t).has_value(); + }))) { + Put(" ::"); // N.B. don't emit some needless ::, pgf90 can crash on them } Put(' '), Walk(std::get>(x.t), ", "); return false; @@ -637,7 +635,7 @@ public: return false; } bool Pre(const PointerStmt &x) { // R853 - Word("POINTER :: "), Walk(x.v, ", "); + Word("POINTER"), Walk(x.v, ", "); return false; } bool Pre(const ProtectedStmt &x) { // R855 @@ -690,12 +688,11 @@ public: Word("IMPORT"); switch (x.kind) { case ImportStmt::Kind::Default: - Put(" :: "); - Walk(x.names); + Walk(" :: ", x.names, ", "); break; case ImportStmt::Kind::Only: Put(", "), Word("ONLY: "); - Walk(x.names); + Walk(x.names, ", "); break; case ImportStmt::Kind::None: Word(", NONE"); break; case ImportStmt::Kind::All: Word(", ALL"); break; @@ -1365,6 +1362,7 @@ public: if (x.format) { Put(", "), Walk(x.format); } + Walk(", ", x.controls, ", "); Put(')'); } else if (x.format) { Walk(x.format); @@ -1372,7 +1370,7 @@ public: Put(", "); } } else { - Put('('), Walk(x.controls), Put(')'); + Put('('), Walk(x.controls, ", "), Put(')'); } Walk(" ", x.items, ", "); return false; @@ -1384,9 +1382,9 @@ public: if (x.format) { Put(", "), Walk(x.format); } - Walk(", ", x.controls); + Walk(", ", x.controls, ", "); } else { - Walk(x.controls); + Walk(x.controls, ", "); } Put(')'), Walk(" ", x.items, ", "); return false;