75 lines · c
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-exception6//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 InputImpliedDo;30struct StatVariable;31} // namespace Fortran::parser32 33namespace Fortran::semantics {34 35// To specify different statement types used in semantic checking.36ENUM_CLASS(StmtType, CYCLE, EXIT)37 38// Perform semantic checks on DO and FORALL constructs and statements.39class DoForallChecker : public virtual BaseChecker {40public:41 explicit DoForallChecker(SemanticsContext &context) : context_{context} {}42 void Leave(const parser::AssignmentStmt &);43 void Leave(const parser::CallStmt &);44 void Leave(const parser::ConnectSpec &);45 void Enter(const parser::CycleStmt &);46 void Enter(const parser::DoConstruct &);47 void Leave(const parser::DoConstruct &);48 void Enter(const parser::ForallConstruct &);49 void Leave(const parser::ForallConstruct &);50 void Enter(const parser::ForallStmt &);51 void Leave(const parser::ForallStmt &);52 void Leave(const parser::ForallAssignmentStmt &s);53 void Enter(const parser::ExitStmt &);54 void Enter(const parser::Expr &);55 void Leave(const parser::Expr &);56 void Leave(const parser::InquireSpec &);57 void Leave(const parser::IoControlSpec &);58 void Leave(const parser::OutputImpliedDo &);59 void Leave(const parser::InputImpliedDo &);60 void Leave(const parser::StatVariable &);61 62private:63 SemanticsContext &context_;64 int exprDepth_{0};65 std::list<SemanticsContext::IndexVarKind> nestedWithinConcurrent_;66 67 void SayBadLeave(68 StmtType, const char *enclosingStmt, const ConstructNode &) const;69 void CheckDoConcurrentExit(StmtType, const ConstructNode &) const;70 void CheckForBadLeave(StmtType, const ConstructNode &) const;71 void CheckNesting(StmtType, const parser::Name *) const;72};73} // namespace Fortran::semantics74#endif75