1//===-- lib/Semantics/check-purity.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_PURITY_H_
10#define FORTRAN_SEMANTICS_CHECK_PURITY_H_
11#include "flang/Semantics/semantics.h"
12#include <list>
13namespace Fortran::parser {
14struct ExecutableConstruct;
15struct SubroutineSubprogram;
16struct FunctionSubprogram;
17struct PrefixSpec;
18} // namespace Fortran::parser
19namespace Fortran::semantics {
20class PurityChecker : public virtual BaseChecker {
21public:
22 explicit PurityChecker(SemanticsContext &c) : context_{c} {}
23 void Enter(const parser::ExecutableConstruct &);
24 void Enter(const parser::SubroutineSubprogram &);
25 void Leave(const parser::SubroutineSubprogram &);
26 void Enter(const parser::FunctionSubprogram &);
27 void Leave(const parser::FunctionSubprogram &);
28
29private:
30 bool InPureSubprogram() const;
31 bool HasPurePrefix(const std::list<parser::PrefixSpec> &) const;
32 void Entered(parser::CharBlock, const std::list<parser::PrefixSpec> &);
33 void Left();
34 SemanticsContext &context_;
35 int depth_{0};
36 int pureDepth_{-1};
37};
38} // namespace Fortran::semantics
39#endif
40

source code of flang/lib/Semantics/check-purity.h