From d39a33f80cd0531e61ba74ee71a49ec42661b1c3 Mon Sep 17 00:00:00 2001 From: peter klausler Date: Tue, 13 Mar 2018 16:59:30 -0700 Subject: [PATCH] [flang] Start on f90_correct. Incorporate review comments. Original-commit: flang-compiler/f18@3f8cecef8efe49778e25a2ab04269b4c07ac6d07 Reviewed-on: https://github.com/flang-compiler/f18/pull/25 Tree-same-pre-rewrite: false --- flang/lib/parser/characters.cc | 6 +++--- flang/lib/parser/unparse.cc | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/flang/lib/parser/characters.cc b/flang/lib/parser/characters.cc index f156a8215f4f..8ead0b7955a3 100644 --- a/flang/lib/parser/characters.cc +++ b/flang/lib/parser/characters.cc @@ -58,11 +58,11 @@ std::optional CountCharacters( const char *limit{p + bytes}; while (p < limit) { ++chars; - if (std::optional cb{cbf(p)}) { - p += *cb; - } else { + std::optional cb{cbf(p)}; + if (!cb.has_value()) { return {}; } + p += *cb; } return {chars}; } diff --git a/flang/lib/parser/unparse.cc b/flang/lib/parser/unparse.cc index 31a9f7e9b064..03688c5c2742 100644 --- a/flang/lib/parser/unparse.cc +++ b/flang/lib/parser/unparse.cc @@ -435,6 +435,18 @@ public: Put(' '), Walk(std::get>(x.t), ", "); return false; } + bool Pre(const AttrSpec &x) { // R802 + std::visit(visitors{[&](const CoarraySpec &y) { Put("CODIMENSION["); }, + [&](const ArraySpec &y) { Put("DIMENSION("); }, + [&](const auto &) {}}, + x.u); + return true; + } + void Post(const AttrSpec &x) { + std::visit(visitors{[&](const CoarraySpec &y) { Put(']'); }, + [&](const ArraySpec &y) { Put(')'); }, [&](const auto &) {}}, + x.u); + } bool Pre(const EntityDecl &x) { // R803 Walk(std::get(x.t)); Walk("(", std::get>(x.t), ")");