2018-12-04 10:55:32 -08:00
|
|
|
// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
|
2018-11-30 14:03:05 -08:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#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
|
|
|
|
void CheckDefinabilityInPureScope(
|
|
|
|
parser::ContextualMessages &, const Symbol &, const Scope &);
|
|
|
|
// 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_
|