FLANG

check-expression.h
1 //===-- include/flang/Evaluate/check-expression.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 // Static expression checking
10
11 #ifndef FORTRAN_EVALUATE_CHECK_EXPRESSION_H_
12 #define FORTRAN_EVALUATE_CHECK_EXPRESSION_H_
13
14 #include "expression.h"
15 #include "intrinsics.h"
16 #include "type.h"
17 #include <optional>
18
19 namespace Fortran::parser {
20 class ContextualMessages;
21 }
22 namespace Fortran::semantics {
23 class Scope;
24 }
25
26 namespace Fortran::evaluate {
27 class IntrinsicProcTable;
28
29 // Predicate: true when an expression is a constant expression (in the
30 // strict sense of the Fortran standard); it may not (yet) be a hard
31 // constant value.
32 template <typename A> bool IsConstantExpr(const A &);
33 extern template bool IsConstantExpr(const Expr<SomeType> &);
34 extern template bool IsConstantExpr(const Expr<SomeInteger> &);
35 extern template bool IsConstantExpr(const Expr<SubscriptInteger> &);
36 extern template bool IsConstantExpr(const StructureConstructor &);
37
38 // Checks whether an expression is an object designator with
39 // constant addressing and no vector-valued subscript.
40 // If a non-null ContextualMessages pointer is passed, an error message
41 // will be generated if and only if the result of the function is false.
42 bool IsInitialDataTarget(
43 const Expr<SomeType> &, parser::ContextualMessages * = nullptr);
44
45 bool IsInitialProcedureTarget(const Symbol &);
46 bool IsInitialProcedureTarget(const ProcedureDesignator &);
47 bool IsInitialProcedureTarget(const Expr<SomeType> &);
48
49 // Check whether an expression is a specification expression
50 // (10.1.11(2), C1010). Constant expressions are always valid
51 // specification expressions.
52
53 template <typename A>
54 void CheckSpecificationExpr(const A &, parser::ContextualMessages &,
55 const semantics::Scope &, const IntrinsicProcTable &);
56 extern template void CheckSpecificationExpr(const Expr<SomeType> &x,
57 parser::ContextualMessages &, const semantics::Scope &,
58 const IntrinsicProcTable &);
59 extern template void CheckSpecificationExpr(const Expr<SomeInteger> &x,
60 parser::ContextualMessages &, const semantics::Scope &,
61 const IntrinsicProcTable &);
62 extern template void CheckSpecificationExpr(const Expr<SubscriptInteger> &x,
63 parser::ContextualMessages &, const semantics::Scope &,
64 const IntrinsicProcTable &);
65 extern template void CheckSpecificationExpr(
66 const std::optional<Expr<SomeType>> &x, parser::ContextualMessages &,
67 const semantics::Scope &, const IntrinsicProcTable &);
68 extern template void CheckSpecificationExpr(
69 const std::optional<Expr<SomeInteger>> &x, parser::ContextualMessages &,
70 const semantics::Scope &, const IntrinsicProcTable &);
71 extern template void CheckSpecificationExpr(
72 const std::optional<Expr<SubscriptInteger>> &x,
73 parser::ContextualMessages &, const semantics::Scope &,
74 const IntrinsicProcTable &);
75
76 // Simple contiguity (9.5.4)
77 template <typename A>
78 bool IsSimplyContiguous(const A &, const IntrinsicProcTable &);
79 extern template bool IsSimplyContiguous(
80 const Expr<SomeType> &, const IntrinsicProcTable &);
81
82 } // namespace Fortran::evaluate
83 #endif
Fortran::parser::ContextualMessages
Definition: message.h:271
Fortran::parser
Definition: check-expression.h:19