2019-12-20 12:52:07 -08:00
|
|
|
//===-- lib/semantics/assignment.h ------------------------------*- C++ -*-===//
|
2018-11-30 14:03:05 -08:00
|
|
|
//
|
2019-12-20 12: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-11-30 14:03:05 -08:00
|
|
|
//
|
2019-12-20 12:52:07 -08:00
|
|
|
//----------------------------------------------------------------------------//
|
2018-11-30 14:03:05 -08:00
|
|
|
|
|
|
|
#ifndef FORTRAN_SEMANTICS_ASSIGNMENT_H_
|
|
|
|
#define FORTRAN_SEMANTICS_ASSIGNMENT_H_
|
|
|
|
|
2019-03-05 16:52:50 -08:00
|
|
|
#include "semantics.h"
|
|
|
|
#include "../common/indirection.h"
|
2019-03-20 11:38:45 -07:00
|
|
|
#include "../evaluate/expression.h"
|
2019-11-01 13:08:16 -07:00
|
|
|
#include <string>
|
2019-03-05 16:52:50 -08:00
|
|
|
|
2018-11-30 14:03:05 -08:00
|
|
|
namespace Fortran::parser {
|
|
|
|
template<typename> struct Statement;
|
|
|
|
struct AssignmentStmt;
|
2018-12-04 10:55:32 -08:00
|
|
|
struct ConcurrentHeader;
|
2018-11-30 14:03:05 -08:00
|
|
|
struct ForallStmt;
|
|
|
|
struct PointerAssignmentStmt;
|
|
|
|
struct Program;
|
|
|
|
struct WhereStmt;
|
2019-03-05 16:52:50 -08:00
|
|
|
struct WhereConstruct;
|
|
|
|
struct ForallStmt;
|
|
|
|
struct ForallConstruct;
|
2018-11-30 14:03:05 -08:00
|
|
|
}
|
|
|
|
|
2019-11-01 13:08:16 -07:00
|
|
|
namespace Fortran::evaluate::characteristics {
|
|
|
|
struct DummyDataObject;
|
|
|
|
}
|
|
|
|
|
2019-03-20 11:38:45 -07:00
|
|
|
namespace Fortran::evaluate {
|
2019-12-11 15:06:24 -08:00
|
|
|
class FoldingContext;
|
|
|
|
void CheckPointerAssignment(
|
|
|
|
FoldingContext &, const Symbol &lhs, const Expr<SomeType> &rhs);
|
|
|
|
void CheckPointerAssignment(FoldingContext &, parser::CharBlock source,
|
2019-11-01 13:08:16 -07:00
|
|
|
const std::string &description, const characteristics::DummyDataObject &,
|
|
|
|
const Expr<SomeType> &rhs);
|
2019-03-20 11:38:45 -07:00
|
|
|
}
|
|
|
|
|
2018-11-30 14:03:05 -08:00
|
|
|
namespace Fortran::semantics {
|
2019-03-05 16:52:50 -08:00
|
|
|
class AssignmentContext;
|
2019-03-20 11:38:45 -07:00
|
|
|
}
|
2019-03-05 16:52:50 -08:00
|
|
|
|
2019-03-20 11:38:45 -07:00
|
|
|
extern template class Fortran::common::Indirection<
|
|
|
|
Fortran::semantics::AssignmentContext>;
|
|
|
|
|
|
|
|
namespace Fortran::semantics {
|
2019-11-19 19:10:02 -08:00
|
|
|
// Applies checks from C1594(1-2) on definitions in PURE subprograms
|
2019-12-18 17:06:13 -08:00
|
|
|
void CheckDefinabilityInPureScope(parser::ContextualMessages &, const Symbol &,
|
|
|
|
const Scope &context, const Scope &pure);
|
2019-11-19 19:10:02 -08:00
|
|
|
// Applies checks from C1594(5-6) on copying pointers in PURE subprograms
|
|
|
|
void CheckCopyabilityInPureScope(parser::ContextualMessages &,
|
|
|
|
const evaluate::Expr<evaluate::SomeType> &, const Scope &);
|
|
|
|
|
2019-03-05 16:52:50 -08:00
|
|
|
class AssignmentChecker : public virtual BaseChecker {
|
|
|
|
public:
|
|
|
|
explicit AssignmentChecker(SemanticsContext &);
|
2019-03-20 11:38:45 -07:00
|
|
|
~AssignmentChecker();
|
2019-11-12 15:43:09 -08:00
|
|
|
template<typename A> void Enter(const parser::Statement<A> &stmt) {
|
|
|
|
at_ = stmt.source;
|
|
|
|
}
|
2019-03-05 16:52:50 -08:00
|
|
|
void Enter(const parser::AssignmentStmt &);
|
|
|
|
void Enter(const parser::PointerAssignmentStmt &);
|
|
|
|
void Enter(const parser::WhereStmt &);
|
|
|
|
void Enter(const parser::WhereConstruct &);
|
|
|
|
void Enter(const parser::ForallStmt &);
|
|
|
|
void Enter(const parser::ForallConstruct &);
|
|
|
|
|
|
|
|
private:
|
2019-03-20 11:38:45 -07:00
|
|
|
common::Indirection<AssignmentContext> context_;
|
2019-11-12 15:43:09 -08:00
|
|
|
parser::CharBlock at_;
|
2019-03-05 16:52:50 -08:00
|
|
|
};
|
2018-11-30 14:03:05 -08:00
|
|
|
|
|
|
|
// Semantic analysis of an assignment statement or WHERE/FORALL construct.
|
|
|
|
void AnalyzeAssignment(
|
|
|
|
SemanticsContext &, const parser::Statement<parser::AssignmentStmt> &);
|
|
|
|
void AnalyzeAssignment(SemanticsContext &,
|
|
|
|
const parser::Statement<parser::PointerAssignmentStmt> &);
|
|
|
|
void AnalyzeAssignment(
|
|
|
|
SemanticsContext &, const parser::Statement<parser::WhereStmt> &);
|
|
|
|
void AnalyzeAssignment(
|
|
|
|
SemanticsContext &, const parser::Statement<parser::ForallStmt> &);
|
|
|
|
|
2018-12-04 10:55:32 -08:00
|
|
|
// R1125 concurrent-header is used in FORALL statements & constructs as
|
|
|
|
// well as in DO CONCURRENT loops.
|
|
|
|
void AnalyzeConcurrentHeader(
|
|
|
|
SemanticsContext &, const parser::ConcurrentHeader &);
|
2018-11-30 14:03:05 -08:00
|
|
|
}
|
|
|
|
#endif // FORTRAN_SEMANTICS_ASSIGNMENT_H_
|