From 8a4b595bf63cf219dda4686617761ff1c4685bf9 Mon Sep 17 00:00:00 2001 From: Jean Perier Date: Tue, 9 Jul 2019 10:40:14 -0700 Subject: [PATCH] [flang] Answer comments * Support target label of label-do on all executable constructs as well as forall and where. * Re-oder and rename related checks in resolve-labels.cc Original-commit: flang-compiler/f18@e5ac8a1660511a7e48f0b2075f87ca1d8dbe23d9 Reviewed-on: https://github.com/flang-compiler/f18/pull/552 Tree-same-pre-rewrite: false --- flang/lib/semantics/canonicalize-do.cc | 34 ++++++++-- flang/lib/semantics/resolve-labels.cc | 66 +++++++++--------- flang/test/semantics/label14.f90 | 119 ++++++++++++++++++++++++++++++--- 3 files changed, 172 insertions(+), 47 deletions(-) diff --git a/flang/lib/semantics/canonicalize-do.cc b/flang/lib/semantics/canonicalize-do.cc index 9f70fbf..995e100 100644 --- a/flang/lib/semantics/canonicalize-do.cc +++ b/flang/lib/semantics/canonicalize-do.cc @@ -34,16 +34,34 @@ public: common::visitors{ [](auto &) {}, // Labels on end-stmt of constructs are accepted by f18 for - // compatibility purposes, even-though they are technically - // not in the same scope as the label-do-stmt. - [&](common::Indirection &ifConstruct) { + // as an extension. + [&](common::Indirection &associate) { CanonicalizeIfMatch(block, stack, i, - std::get>(ifConstruct.value().t)); + std::get>( + associate.value().t)); + }, + [&](common::Indirection &blockConstruct) { + CanonicalizeIfMatch(block, stack, i, + std::get>( + blockConstruct.value().t)); + }, + [&](common::Indirection &changeTeam) { + CanonicalizeIfMatch(block, stack, i, + std::get>( + changeTeam.value().t)); + }, + [&](common::Indirection &critical) { + CanonicalizeIfMatch(block, stack, i, + std::get>(critical.value().t)); }, [&](common::Indirection &doConstruct) { CanonicalizeIfMatch(block, stack, i, std::get>(doConstruct.value().t)); }, + [&](common::Indirection &ifConstruct) { + CanonicalizeIfMatch(block, stack, i, + std::get>(ifConstruct.value().t)); + }, [&](common::Indirection &caseConstruct) { CanonicalizeIfMatch(block, stack, i, std::get>( @@ -57,6 +75,14 @@ public: CanonicalizeIfMatch(block, stack, i, std::get>(selectType.value().t)); }, + [&](common::Indirection &forall) { + CanonicalizeIfMatch(block, stack, i, + std::get>(forall.value().t)); + }, + [&](common::Indirection &where) { + CanonicalizeIfMatch(block, stack, i, + std::get>(where.value().t)); + }, [&](Statement> &labelDoStmt) { auto &label{std::get