2020-02-25 23:11:52 +08:00
|
|
|
//===-- lib/Semantics/check-do-forall.h -------------------------*- C++ -*-===//
|
2018-09-18 08:19:27 +08:00
|
|
|
//
|
2019-12-21 04:52:07 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-09-18 08:19:27 +08:00
|
|
|
//
|
2020-01-11 04:12:03 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-09-18 08:19:27 +08:00
|
|
|
|
2020-02-20 05:28:19 +08:00
|
|
|
#ifndef FORTRAN_SEMANTICS_CHECK_DO_FORALL_H_
|
|
|
|
#define FORTRAN_SEMANTICS_CHECK_DO_FORALL_H_
|
2018-09-18 08:19:27 +08:00
|
|
|
|
2020-02-25 23:11:52 +08:00
|
|
|
#include "flang/Common/idioms.h"
|
|
|
|
#include "flang/Semantics/semantics.h"
|
2019-06-06 02:57:09 +08:00
|
|
|
|
|
|
|
namespace Fortran::parser {
|
2019-12-07 11:59:54 +08:00
|
|
|
struct AssignmentStmt;
|
2020-01-03 04:26:47 +08:00
|
|
|
struct CallStmt;
|
2019-12-07 11:59:54 +08:00
|
|
|
struct ConnectSpec;
|
2019-08-30 07:02:37 +08:00
|
|
|
struct CycleStmt;
|
2019-12-07 11:59:54 +08:00
|
|
|
struct DoConstruct;
|
2019-08-30 07:02:37 +08:00
|
|
|
struct ExitStmt;
|
2020-01-10 03:37:51 +08:00
|
|
|
struct Expr;
|
2020-02-19 09:14:24 +08:00
|
|
|
struct ForallAssignmentStmt;
|
|
|
|
struct ForallConstruct;
|
|
|
|
struct ForallStmt;
|
2019-12-07 11:59:54 +08:00
|
|
|
struct InquireSpec;
|
|
|
|
struct IoControlSpec;
|
|
|
|
struct OutputImpliedDo;
|
|
|
|
struct StatVariable;
|
2020-03-29 12:00:16 +08:00
|
|
|
} // namespace Fortran::parser
|
2019-03-06 08:52:50 +08:00
|
|
|
|
2018-09-18 08:19:27 +08:00
|
|
|
namespace Fortran::semantics {
|
2019-03-06 08:52:50 +08:00
|
|
|
|
2019-10-01 04:52:05 +08:00
|
|
|
// To specify different statement types used in semantic checking.
|
2019-10-12 05:39:33 +08:00
|
|
|
ENUM_CLASS(StmtType, CYCLE, EXIT)
|
2019-09-25 01:44:44 +08:00
|
|
|
|
2020-02-20 05:28:19 +08:00
|
|
|
// Perform semantic checks on DO and FORALL constructs and statements.
|
|
|
|
class DoForallChecker : public virtual BaseChecker {
|
2019-03-06 08:52:50 +08:00
|
|
|
public:
|
2020-02-20 05:28:19 +08:00
|
|
|
explicit DoForallChecker(SemanticsContext &context) : context_{context} {}
|
2019-12-07 11:59:54 +08:00
|
|
|
void Leave(const parser::AssignmentStmt &);
|
2020-01-03 04:26:47 +08:00
|
|
|
void Leave(const parser::CallStmt &);
|
2019-12-07 11:59:54 +08:00
|
|
|
void Leave(const parser::ConnectSpec &);
|
2019-08-27 07:26:24 +08:00
|
|
|
void Enter(const parser::CycleStmt &);
|
2019-12-07 11:59:54 +08:00
|
|
|
void Enter(const parser::DoConstruct &);
|
|
|
|
void Leave(const parser::DoConstruct &);
|
2020-02-19 09:14:24 +08:00
|
|
|
void Enter(const parser::ForallConstruct &);
|
|
|
|
void Leave(const parser::ForallConstruct &);
|
|
|
|
void Enter(const parser::ForallStmt &);
|
|
|
|
void Leave(const parser::ForallStmt &);
|
|
|
|
void Leave(const parser::ForallAssignmentStmt &s);
|
2019-08-27 07:26:24 +08:00
|
|
|
void Enter(const parser::ExitStmt &);
|
2020-06-03 23:03:14 +08:00
|
|
|
void Enter(const parser::Expr &);
|
2020-01-10 03:37:51 +08:00
|
|
|
void Leave(const parser::Expr &);
|
2019-12-07 11:59:54 +08:00
|
|
|
void Leave(const parser::InquireSpec &);
|
|
|
|
void Leave(const parser::IoControlSpec &);
|
|
|
|
void Leave(const parser::OutputImpliedDo &);
|
|
|
|
void Leave(const parser::StatVariable &);
|
2019-03-06 08:52:50 +08:00
|
|
|
|
|
|
|
private:
|
2019-06-05 06:14:34 +08:00
|
|
|
SemanticsContext &context_;
|
2020-06-03 23:03:14 +08:00
|
|
|
int exprDepth_{0};
|
2019-09-23 01:01:03 +08:00
|
|
|
|
2019-09-25 01:44:44 +08:00
|
|
|
void SayBadLeave(
|
|
|
|
StmtType, const char *enclosingStmt, const ConstructNode &) const;
|
|
|
|
void CheckDoConcurrentExit(StmtType, const ConstructNode &) const;
|
|
|
|
void CheckForBadLeave(StmtType, const ConstructNode &) const;
|
|
|
|
void CheckNesting(StmtType, const parser::Name *) const;
|
2019-03-06 08:52:50 +08:00
|
|
|
};
|
2020-03-29 12:00:16 +08:00
|
|
|
} // namespace Fortran::semantics
|
2020-02-20 05:28:19 +08:00
|
|
|
#endif
|