From: peter klausler Date: Mon, 1 Apr 2019 23:15:47 +0000 (-0700) Subject: [flang] some debugging after more testing X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=39b74331943416d0e3eb3e059e597d185917ca46;p=platform%2Fupstream%2Fllvm.git [flang] some debugging after more testing Original-commit: flang-compiler/f18@005b841dd1140a809fb8123ed5b02048b8e1a4d3 Reviewed-on: https://github.com/flang-compiler/f18/pull/373 --- diff --git a/flang/lib/parser/dump-parse-tree.h b/flang/lib/parser/dump-parse-tree.h index 818e03e..287e9ee 100644 --- a/flang/lib/parser/dump-parse-tree.h +++ b/flang/lib/parser/dump-parse-tree.h @@ -790,6 +790,8 @@ public: bool Pre(const parser::CharBlock &) { return true; } void Post(const parser::CharBlock &) {} + template bool Pre(const parser::Statement &) { return true; } + template void Post(const parser::Statement &) {} template bool Pre(const parser::UnlabeledStatement &) { return true; } diff --git a/flang/lib/parser/parse-tree-visitor.h b/flang/lib/parser/parse-tree-visitor.h index 4434106..15a760a 100644 --- a/flang/lib/parser/parse-tree-visitor.h +++ b/flang/lib/parser/parse-tree-visitor.h @@ -291,6 +291,23 @@ template void Walk(DefaultChar &x, M &mutator) { } } +template void Walk(const Statement &x, V &visitor) { + if (visitor.Pre(x)) { + // N.B. The label, if any, is not visited. + Walk(x.source, visitor); + Walk(x.statement, visitor); + visitor.Post(x); + } +} +template void Walk(Statement &x, M &mutator) { + if (mutator.Pre(x)) { + // N.B. The label, if any, is not visited. + Walk(x.source, mutator); + Walk(x.statement, mutator); + mutator.Post(x); + } +} + template void Walk(const UnlabeledStatement &x, V &visitor) { if (visitor.Pre(x)) { diff --git a/flang/lib/parser/stmt-parser.h b/flang/lib/parser/stmt-parser.h index 88affd1..021fa7f 100644 --- a/flang/lib/parser/stmt-parser.h +++ b/flang/lib/parser/stmt-parser.h @@ -51,10 +51,8 @@ template inline constexpr auto statement(const PA &p) { // unlabeledStatement() is basically statement() for those few situations // in Fortran where a statement cannot have a label. template inline constexpr auto unlabeledStatement(const PA &p) { - return skipStuffBeforeStatement >> - sourced( - construct>(space >> p)) / - endOfStmt; + return space >> + sourced(construct>(p)); } // This unambiguousStatement() variant of statement() provides better error