1//===-- lib/Semantics/check-do-forall.h -------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef FORTRAN_SEMANTICS_CHECK_DO_FORALL_H_
10#define FORTRAN_SEMANTICS_CHECK_DO_FORALL_H_
11
12#include "flang/Common/idioms.h"
13#include "flang/Semantics/semantics.h"
14
15namespace Fortran::parser {
16struct AssignmentStmt;
17struct CallStmt;
18struct ConnectSpec;
19struct CycleStmt;
20struct DoConstruct;
21struct ExitStmt;
22struct Expr;
23struct ForallAssignmentStmt;
24struct ForallConstruct;
25struct ForallStmt;
26struct InquireSpec;
27struct IoControlSpec;
28struct OutputImpliedDo;
29struct StatVariable;
30} // namespace Fortran::parser
31
32namespace Fortran::semantics {
33
34// To specify different statement types used in semantic checking.
35ENUM_CLASS(StmtType, CYCLE, EXIT)
36
37// Perform semantic checks on DO and FORALL constructs and statements.
38class DoForallChecker : public virtual BaseChecker {
39public:
40 explicit DoForallChecker(SemanticsContext &context) : context_{context} {}
41 void Leave(const parser::AssignmentStmt &);
42 void Leave(const parser::CallStmt &);
43 void Leave(const parser::ConnectSpec &);
44 void Enter(const parser::CycleStmt &);
45 void Enter(const parser::DoConstruct &);
46 void Leave(const parser::DoConstruct &);
47 void Enter(const parser::ForallConstruct &);
48 void Leave(const parser::ForallConstruct &);
49 void Enter(const parser::ForallStmt &);
50 void Leave(const parser::ForallStmt &);
51 void Leave(const parser::ForallAssignmentStmt &s);
52 void Enter(const parser::ExitStmt &);
53 void Enter(const parser::Expr &);
54 void Leave(const parser::Expr &);
55 void Leave(const parser::InquireSpec &);
56 void Leave(const parser::IoControlSpec &);
57 void Leave(const parser::OutputImpliedDo &);
58 void Leave(const parser::StatVariable &);
59
60private:
61 SemanticsContext &context_;
62 int exprDepth_{0};
63
64 void SayBadLeave(
65 StmtType, const char *enclosingStmt, const ConstructNode &) const;
66 void CheckDoConcurrentExit(StmtType, const ConstructNode &) const;
67 void CheckForBadLeave(StmtType, const ConstructNode &) const;
68 void CheckNesting(StmtType, const parser::Name *) const;
69};
70} // namespace Fortran::semantics
71#endif
72

source code of flang/lib/Semantics/check-do-forall.h