blob: d55fa16001335b7c5e06b5a887c7ac8b3ea326f4 [file] [log] [blame]
CarolineConcatto64ab3302020-02-25 15:11:521//===-- lib/Semantics/pointer-assignment.cpp ------------------------------===//
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#include "pointer-assignment.h"
10#include "flang/Common/idioms.h"
11#include "flang/Common/restorer.h"
12#include "flang/Evaluate/characteristics.h"
13#include "flang/Evaluate/expression.h"
14#include "flang/Evaluate/fold.h"
15#include "flang/Evaluate/tools.h"
16#include "flang/Parser/message.h"
17#include "flang/Parser/parse-tree-visitor.h"
18#include "flang/Parser/parse-tree.h"
19#include "flang/Semantics/expression.h"
20#include "flang/Semantics/symbol.h"
21#include "flang/Semantics/tools.h"
Caroline Concatto8670e492020-02-28 15:11:0322#include "llvm/Support/raw_ostream.h"
CarolineConcatto64ab3302020-02-25 15:11:5223#include <optional>
24#include <set>
25#include <string>
26#include <type_traits>
27
28// Semantic checks for pointer assignment.
29
30namespace Fortran::semantics {
31
32using namespace parser::literals;
33using evaluate::characteristics::DummyDataObject;
34using evaluate::characteristics::FunctionResult;
35using evaluate::characteristics::Procedure;
36using evaluate::characteristics::TypeAndShape;
37using parser::MessageFixedText;
38using parser::MessageFormattedText;
39
40class PointerAssignmentChecker {
41public:
42 PointerAssignmentChecker(evaluate::FoldingContext &context,
43 parser::CharBlock source, const std::string &description)
Tim Keith1f879002020-03-29 04:00:1644 : context_{context}, source_{source}, description_{description} {}
CarolineConcatto64ab3302020-02-25 15:11:5245 PointerAssignmentChecker(evaluate::FoldingContext &context, const Symbol &lhs)
Tim Keith1f879002020-03-29 04:00:1646 : context_{context}, source_{lhs.name()},
peter klausler562bfe12021-06-15 22:17:1647 description_{"pointer '"s + lhs.name().ToString() + '\''}, lhs_{&lhs} {
CarolineConcatto64ab3302020-02-25 15:11:5248 set_lhsType(TypeAndShape::Characterize(lhs, context));
49 set_isContiguous(lhs.attrs().test(Attr::CONTIGUOUS));
50 set_isVolatile(lhs.attrs().test(Attr::VOLATILE));
peter klausler562bfe12021-06-15 22:17:1651 if (IsProcedure(lhs)) {
52 procedure_ = Procedure::Characterize(lhs, context);
53 }
CarolineConcatto64ab3302020-02-25 15:11:5254 }
55 PointerAssignmentChecker &set_lhsType(std::optional<TypeAndShape> &&);
56 PointerAssignmentChecker &set_isContiguous(bool);
57 PointerAssignmentChecker &set_isVolatile(bool);
58 PointerAssignmentChecker &set_isBoundsRemapping(bool);
peter klausler4171f802020-06-19 00:17:0459 bool Check(const SomeExpr &);
CarolineConcatto64ab3302020-02-25 15:11:5260
61private:
peter klausler4171f802020-06-19 00:17:0462 template <typename T> bool Check(const T &);
63 template <typename T> bool Check(const evaluate::Expr<T> &);
64 template <typename T> bool Check(const evaluate::FunctionRef<T> &);
65 template <typename T> bool Check(const evaluate::Designator<T> &);
66 bool Check(const evaluate::NullPointer &);
67 bool Check(const evaluate::ProcedureDesignator &);
68 bool Check(const evaluate::ProcedureRef &);
CarolineConcatto64ab3302020-02-25 15:11:5269 // Target is a procedure
peter klausler4171f802020-06-19 00:17:0470 bool Check(
CarolineConcatto64ab3302020-02-25 15:11:5271 parser::CharBlock rhsName, bool isCall, const Procedure * = nullptr);
72 bool LhsOkForUnlimitedPoly() const;
Tim Keith1f879002020-03-29 04:00:1673 template <typename... A> parser::Message *Say(A &&...);
CarolineConcatto64ab3302020-02-25 15:11:5274
75 evaluate::FoldingContext &context_;
76 const parser::CharBlock source_;
77 const std::string description_;
78 const Symbol *lhs_{nullptr};
79 std::optional<TypeAndShape> lhsType_;
80 std::optional<Procedure> procedure_;
81 bool isContiguous_{false};
82 bool isVolatile_{false};
83 bool isBoundsRemapping_{false};
84};
85
86PointerAssignmentChecker &PointerAssignmentChecker::set_lhsType(
87 std::optional<TypeAndShape> &&lhsType) {
88 lhsType_ = std::move(lhsType);
89 return *this;
90}
91
92PointerAssignmentChecker &PointerAssignmentChecker::set_isContiguous(
93 bool isContiguous) {
94 isContiguous_ = isContiguous;
95 return *this;
96}
97
98PointerAssignmentChecker &PointerAssignmentChecker::set_isVolatile(
99 bool isVolatile) {
100 isVolatile_ = isVolatile;
101 return *this;
102}
103
104PointerAssignmentChecker &PointerAssignmentChecker::set_isBoundsRemapping(
105 bool isBoundsRemapping) {
106 isBoundsRemapping_ = isBoundsRemapping;
107 return *this;
108}
109
peter klausler4171f802020-06-19 00:17:04110template <typename T> bool PointerAssignmentChecker::Check(const T &) {
CarolineConcatto64ab3302020-02-25 15:11:52111 // Catch-all case for really bad target expression
112 Say("Target associated with %s must be a designator or a call to a"
113 " pointer-valued function"_err_en_US,
114 description_);
peter klausler4171f802020-06-19 00:17:04115 return false;
CarolineConcatto64ab3302020-02-25 15:11:52116}
117
Tim Keith1f879002020-03-29 04:00:16118template <typename T>
peter klausler4171f802020-06-19 00:17:04119bool PointerAssignmentChecker::Check(const evaluate::Expr<T> &x) {
Peter Klauslercd03e962022-03-23 21:05:50120 return common::visit([&](const auto &x) { return Check(x); }, x.u);
CarolineConcatto64ab3302020-02-25 15:11:52121}
122
peter klausler4171f802020-06-19 00:17:04123bool PointerAssignmentChecker::Check(const SomeExpr &rhs) {
Tim Keith1f879002020-03-29 04:00:16124 if (HasVectorSubscript(rhs)) { // C1025
CarolineConcatto64ab3302020-02-25 15:11:52125 Say("An array section with a vector subscript may not be a pointer target"_err_en_US);
peter klausler4171f802020-06-19 00:17:04126 return false;
Tim Keith1f879002020-03-29 04:00:16127 } else if (ExtractCoarrayRef(rhs)) { // C1026
CarolineConcatto64ab3302020-02-25 15:11:52128 Say("A coindexed object may not be a pointer target"_err_en_US);
peter klausler4171f802020-06-19 00:17:04129 return false;
CarolineConcatto64ab3302020-02-25 15:11:52130 } else {
Peter Klauslercd03e962022-03-23 21:05:50131 return common::visit([&](const auto &x) { return Check(x); }, rhs.u);
CarolineConcatto64ab3302020-02-25 15:11:52132 }
133}
134
peter klausler4171f802020-06-19 00:17:04135bool PointerAssignmentChecker::Check(const evaluate::NullPointer &) {
136 return true; // P => NULL() without MOLD=; always OK
CarolineConcatto64ab3302020-02-25 15:11:52137}
138
Tim Keith1f879002020-03-29 04:00:16139template <typename T>
peter klausler4171f802020-06-19 00:17:04140bool PointerAssignmentChecker::Check(const evaluate::FunctionRef<T> &f) {
CarolineConcatto64ab3302020-02-25 15:11:52141 std::string funcName;
142 const auto *symbol{f.proc().GetSymbol()};
143 if (symbol) {
144 funcName = symbol->name().ToString();
145 } else if (const auto *intrinsic{f.proc().GetSpecificIntrinsic()}) {
146 funcName = intrinsic->name;
147 }
peter klausler641ede92020-12-07 20:08:58148 auto proc{Procedure::Characterize(f.proc(), context_)};
CarolineConcatto64ab3302020-02-25 15:11:52149 if (!proc) {
peter klausler4171f802020-06-19 00:17:04150 return false;
CarolineConcatto64ab3302020-02-25 15:11:52151 }
152 std::optional<MessageFixedText> msg;
Tim Keith1f879002020-03-29 04:00:16153 const auto &funcResult{proc->functionResult}; // C1025
CarolineConcatto64ab3302020-02-25 15:11:52154 if (!funcResult) {
155 msg = "%s is associated with the non-existent result of reference to"
156 " procedure"_err_en_US;
157 } else if (procedure_) {
158 // Shouldn't be here in this function unless lhs is an object pointer.
159 msg = "Procedure %s is associated with the result of a reference to"
160 " function '%s' that does not return a procedure pointer"_err_en_US;
161 } else if (funcResult->IsProcedurePointer()) {
162 msg = "Object %s is associated with the result of a reference to"
163 " function '%s' that is a procedure pointer"_err_en_US;
164 } else if (!funcResult->attrs.test(FunctionResult::Attr::Pointer)) {
165 msg = "%s is associated with the result of a reference to function '%s'"
166 " that is a not a pointer"_err_en_US;
167 } else if (isContiguous_ &&
168 !funcResult->attrs.test(FunctionResult::Attr::Contiguous)) {
169 msg = "CONTIGUOUS %s is associated with the result of reference to"
170 " function '%s' that is not contiguous"_err_en_US;
171 } else if (lhsType_) {
172 const auto *frTypeAndShape{funcResult->GetTypeAndShape()};
173 CHECK(frTypeAndShape);
peter klauslerd6a74ec2020-12-15 18:54:36174 if (!lhsType_->IsCompatibleWith(context_.messages(), *frTypeAndShape,
Peter Klausler7763c012022-02-08 21:49:40175 "pointer", "function result",
176 isBoundsRemapping_ /*omit shape check*/,
peter klauslerdfecbca2021-06-03 22:48:16177 evaluate::CheckConformanceFlags::BothDeferredShape)) {
peter klauslerbcb25912021-09-17 15:19:10178 return false; // IsCompatibleWith() emitted message
CarolineConcatto64ab3302020-02-25 15:11:52179 }
180 }
181 if (msg) {
182 auto restorer{common::ScopedSet(lhs_, symbol)};
183 Say(*msg, description_, funcName);
peter klausler4171f802020-06-19 00:17:04184 return false;
CarolineConcatto64ab3302020-02-25 15:11:52185 }
peter klausler4171f802020-06-19 00:17:04186 return true;
CarolineConcatto64ab3302020-02-25 15:11:52187}
188
Tim Keith1f879002020-03-29 04:00:16189template <typename T>
peter klausler4171f802020-06-19 00:17:04190bool PointerAssignmentChecker::Check(const evaluate::Designator<T> &d) {
CarolineConcatto64ab3302020-02-25 15:11:52191 const Symbol *last{d.GetLastSymbol()};
192 const Symbol *base{d.GetBaseObject().symbol()};
193 if (!last || !base) {
194 // P => "character literal"(1:3)
195 context_.messages().Say("Pointer target is not a named entity"_err_en_US);
peter klausler4171f802020-06-19 00:17:04196 return false;
CarolineConcatto64ab3302020-02-25 15:11:52197 }
198 std::optional<std::variant<MessageFixedText, MessageFormattedText>> msg;
199 if (procedure_) {
200 // Shouldn't be here in this function unless lhs is an object pointer.
201 msg = "In assignment to procedure %s, the target is not a procedure or"
202 " procedure pointer"_err_en_US;
Tim Keith1f879002020-03-29 04:00:16203 } else if (!evaluate::GetLastTarget(GetSymbolVector(d))) { // C1025
CarolineConcatto64ab3302020-02-25 15:11:52204 msg = "In assignment to object %s, the target '%s' is not an object with"
205 " POINTER or TARGET attributes"_err_en_US;
206 } else if (auto rhsType{TypeAndShape::Characterize(d, context_)}) {
207 if (!lhsType_) {
208 msg = "%s associated with object '%s' with incompatible type or"
209 " shape"_err_en_US;
210 } else if (rhsType->corank() > 0 &&
Tim Keith1f879002020-03-29 04:00:16211 (isVolatile_ != last->attrs().test(Attr::VOLATILE))) { // C1020
CarolineConcatto64ab3302020-02-25 15:11:52212 // TODO: what if A is VOLATILE in A%B%C? need a better test here
213 if (isVolatile_) {
214 msg = "Pointer may not be VOLATILE when target is a"
215 " non-VOLATILE coarray"_err_en_US;
216 } else {
217 msg = "Pointer must be VOLATILE when target is a"
218 " VOLATILE coarray"_err_en_US;
219 }
220 } else if (rhsType->type().IsUnlimitedPolymorphic()) {
221 if (!LhsOkForUnlimitedPoly()) {
222 msg = "Pointer type must be unlimited polymorphic or non-extensible"
223 " derived type when target is unlimited polymorphic"_err_en_US;
224 }
225 } else {
peter klausler37b2e2b2020-09-30 20:34:23226 if (!lhsType_->type().IsTkCompatibleWith(rhsType->type())) {
CarolineConcatto64ab3302020-02-25 15:11:52227 msg = MessageFormattedText{
228 "Target type %s is not compatible with pointer type %s"_err_en_US,
229 rhsType->type().AsFortran(), lhsType_->type().AsFortran()};
230
231 } else if (!isBoundsRemapping_) {
peter klauslerf862d852020-08-31 18:54:48232 int lhsRank{evaluate::GetRank(lhsType_->shape())};
233 int rhsRank{evaluate::GetRank(rhsType->shape())};
CarolineConcatto64ab3302020-02-25 15:11:52234 if (lhsRank != rhsRank) {
235 msg = MessageFormattedText{
236 "Pointer has rank %d but target has rank %d"_err_en_US, lhsRank,
237 rhsRank};
238 }
239 }
240 }
241 }
242 if (msg) {
243 auto restorer{common::ScopedSet(lhs_, last)};
244 if (auto *m{std::get_if<MessageFixedText>(&*msg)}) {
Caroline Concatto8670e492020-02-28 15:11:03245 std::string buf;
246 llvm::raw_string_ostream ss{buf};
CarolineConcatto64ab3302020-02-25 15:11:52247 d.AsFortran(ss);
248 Say(*m, description_, ss.str());
249 } else {
250 Say(std::get<MessageFormattedText>(*msg));
251 }
peter klausler4171f802020-06-19 00:17:04252 return false;
CarolineConcatto64ab3302020-02-25 15:11:52253 }
peter klausler4171f802020-06-19 00:17:04254 return true;
CarolineConcatto64ab3302020-02-25 15:11:52255}
256
CarolineConcatto64ab3302020-02-25 15:11:52257// Common handling for procedure pointer right-hand sides
peter klausler4171f802020-06-19 00:17:04258bool PointerAssignmentChecker::Check(
CarolineConcatto64ab3302020-02-25 15:11:52259 parser::CharBlock rhsName, bool isCall, const Procedure *rhsProcedure) {
Peter Steinfeldc7574182020-09-25 16:03:17260 if (std::optional<MessageFixedText> msg{
261 evaluate::CheckProcCompatibility(isCall, procedure_, rhsProcedure)}) {
CarolineConcatto64ab3302020-02-25 15:11:52262 Say(std::move(*msg), description_, rhsName);
peter klausler4171f802020-06-19 00:17:04263 return false;
CarolineConcatto64ab3302020-02-25 15:11:52264 }
peter klausler4171f802020-06-19 00:17:04265 return true;
CarolineConcatto64ab3302020-02-25 15:11:52266}
267
peter klausler4171f802020-06-19 00:17:04268bool PointerAssignmentChecker::Check(const evaluate::ProcedureDesignator &d) {
peter klausler641ede92020-12-07 20:08:58269 if (auto chars{Procedure::Characterize(d, context_)}) {
peter klausler4171f802020-06-19 00:17:04270 return Check(d.GetName(), false, &*chars);
CarolineConcatto64ab3302020-02-25 15:11:52271 } else {
peter klausler4171f802020-06-19 00:17:04272 return Check(d.GetName(), false);
CarolineConcatto64ab3302020-02-25 15:11:52273 }
274}
275
peter klausler4171f802020-06-19 00:17:04276bool PointerAssignmentChecker::Check(const evaluate::ProcedureRef &ref) {
CarolineConcatto64ab3302020-02-25 15:11:52277 const Procedure *procedure{nullptr};
peter klausler641ede92020-12-07 20:08:58278 auto chars{Procedure::Characterize(ref, context_)};
CarolineConcatto64ab3302020-02-25 15:11:52279 if (chars) {
280 procedure = &*chars;
281 if (chars->functionResult) {
282 if (const auto *proc{chars->functionResult->IsProcedurePointer()}) {
283 procedure = proc;
284 }
285 }
286 }
peter klausler4171f802020-06-19 00:17:04287 return Check(ref.proc().GetName(), true, procedure);
CarolineConcatto64ab3302020-02-25 15:11:52288}
289
290// The target can be unlimited polymorphic if the pointer is, or if it is
291// a non-extensible derived type.
292bool PointerAssignmentChecker::LhsOkForUnlimitedPoly() const {
293 const auto &type{lhsType_->type()};
294 if (type.category() != TypeCategory::Derived || type.IsAssumedType()) {
295 return false;
296 } else if (type.IsUnlimitedPolymorphic()) {
297 return true;
298 } else {
299 return !IsExtensibleType(&type.GetDerivedTypeSpec());
300 }
301}
302
Tim Keith1f879002020-03-29 04:00:16303template <typename... A>
peter klausler0e9e06a2020-08-06 23:56:14304parser::Message *PointerAssignmentChecker::Say(A &&...x) {
CarolineConcatto64ab3302020-02-25 15:11:52305 auto *msg{context_.messages().Say(std::forward<A>(x)...)};
peter klausler641ede92020-12-07 20:08:58306 if (msg) {
307 if (lhs_) {
308 return evaluate::AttachDeclaration(msg, *lhs_);
309 }
310 if (!source_.empty()) {
311 msg->Attach(source_, "Declaration of %s"_en_US, description_);
312 }
CarolineConcatto64ab3302020-02-25 15:11:52313 }
314 return msg;
315}
316
317// Verify that any bounds on the LHS of a pointer assignment are valid.
318// Return true if it is a bound-remapping so we can perform further checks.
319static bool CheckPointerBounds(
320 evaluate::FoldingContext &context, const evaluate::Assignment &assignment) {
321 auto &messages{context.messages()};
322 const SomeExpr &lhs{assignment.lhs};
323 const SomeExpr &rhs{assignment.rhs};
324 bool isBoundsRemapping{false};
Peter Klauslercd03e962022-03-23 21:05:50325 std::size_t numBounds{common::visit(
CarolineConcatto64ab3302020-02-25 15:11:52326 common::visitors{
327 [&](const evaluate::Assignment::BoundsSpec &bounds) {
328 return bounds.size();
329 },
330 [&](const evaluate::Assignment::BoundsRemapping &bounds) {
331 isBoundsRemapping = true;
332 evaluate::ExtentExpr lhsSizeExpr{1};
333 for (const auto &bound : bounds) {
334 lhsSizeExpr = std::move(lhsSizeExpr) *
335 (common::Clone(bound.second) - common::Clone(bound.first) +
336 evaluate::ExtentExpr{1});
337 }
338 if (std::optional<std::int64_t> lhsSize{evaluate::ToInt64(
339 evaluate::Fold(context, std::move(lhsSizeExpr)))}) {
340 if (auto shape{evaluate::GetShape(context, rhs)}) {
341 if (std::optional<std::int64_t> rhsSize{
342 evaluate::ToInt64(evaluate::Fold(
343 context, evaluate::GetSize(std::move(*shape))))}) {
344 if (*lhsSize > *rhsSize) {
345 messages.Say(
346 "Pointer bounds require %d elements but target has"
347 " only %d"_err_en_US,
Tim Keith1f879002020-03-29 04:00:16348 *lhsSize, *rhsSize); // 10.2.2.3(9)
CarolineConcatto64ab3302020-02-25 15:11:52349 }
350 }
351 }
352 }
353 return bounds.size();
354 },
355 [](const auto &) -> std::size_t {
356 DIE("not valid for pointer assignment");
357 },
358 },
359 assignment.u)};
360 if (numBounds > 0) {
361 if (lhs.Rank() != static_cast<int>(numBounds)) {
362 messages.Say("Pointer '%s' has rank %d but the number of bounds specified"
363 " is %d"_err_en_US,
Tim Keith1f879002020-03-29 04:00:16364 lhs.AsFortran(), lhs.Rank(), numBounds); // C1018
CarolineConcatto64ab3302020-02-25 15:11:52365 }
366 }
367 if (isBoundsRemapping && rhs.Rank() != 1 &&
peter klausler641ede92020-12-07 20:08:58368 !evaluate::IsSimplyContiguous(rhs, context)) {
CarolineConcatto64ab3302020-02-25 15:11:52369 messages.Say("Pointer bounds remapping target must have rank 1 or be"
Tim Keith1f879002020-03-29 04:00:16370 " simply contiguous"_err_en_US); // 10.2.2.3(9)
CarolineConcatto64ab3302020-02-25 15:11:52371 }
372 return isBoundsRemapping;
373}
374
peter klausler4171f802020-06-19 00:17:04375bool CheckPointerAssignment(
CarolineConcatto64ab3302020-02-25 15:11:52376 evaluate::FoldingContext &context, const evaluate::Assignment &assignment) {
peter klausler4171f802020-06-19 00:17:04377 return CheckPointerAssignment(context, assignment.lhs, assignment.rhs,
378 CheckPointerBounds(context, assignment));
379}
380
381bool CheckPointerAssignment(evaluate::FoldingContext &context,
382 const SomeExpr &lhs, const SomeExpr &rhs, bool isBoundsRemapping) {
CarolineConcatto64ab3302020-02-25 15:11:52383 const Symbol *pointer{GetLastSymbol(lhs)};
384 if (!pointer) {
peter klausler4171f802020-06-19 00:17:04385 return false; // error was reported
CarolineConcatto64ab3302020-02-25 15:11:52386 }
Kiran Chandramohan48dc5c82021-11-04 17:50:20387 if (!IsPointer(pointer->GetUltimate())) {
CarolineConcatto64ab3302020-02-25 15:11:52388 evaluate::SayWithDeclaration(context.messages(), *pointer,
389 "'%s' is not a pointer"_err_en_US, pointer->name());
peter klausler4171f802020-06-19 00:17:04390 return false;
CarolineConcatto64ab3302020-02-25 15:11:52391 }
392 if (pointer->has<ProcEntityDetails>() && evaluate::ExtractCoarrayRef(lhs)) {
Tim Keith1f879002020-03-29 04:00:16393 context.messages().Say( // C1027
CarolineConcatto64ab3302020-02-25 15:11:52394 "Procedure pointer may not be a coindexed object"_err_en_US);
peter klausler4171f802020-06-19 00:17:04395 return false;
CarolineConcatto64ab3302020-02-25 15:11:52396 }
peter klausler4171f802020-06-19 00:17:04397 return PointerAssignmentChecker{context, *pointer}
CarolineConcatto64ab3302020-02-25 15:11:52398 .set_isBoundsRemapping(isBoundsRemapping)
399 .Check(rhs);
400}
401
peter klausler4171f802020-06-19 00:17:04402bool CheckPointerAssignment(
CarolineConcatto64ab3302020-02-25 15:11:52403 evaluate::FoldingContext &context, const Symbol &lhs, const SomeExpr &rhs) {
404 CHECK(IsPointer(lhs));
peter klausler4171f802020-06-19 00:17:04405 return PointerAssignmentChecker{context, lhs}.Check(rhs);
CarolineConcatto64ab3302020-02-25 15:11:52406}
407
peter klausler4171f802020-06-19 00:17:04408bool CheckPointerAssignment(evaluate::FoldingContext &context,
CarolineConcatto64ab3302020-02-25 15:11:52409 parser::CharBlock source, const std::string &description,
410 const DummyDataObject &lhs, const SomeExpr &rhs) {
peter klausler4171f802020-06-19 00:17:04411 return PointerAssignmentChecker{context, source, description}
CarolineConcatto64ab3302020-02-25 15:11:52412 .set_lhsType(common::Clone(lhs.type))
413 .set_isContiguous(lhs.attrs.test(DummyDataObject::Attr::Contiguous))
414 .set_isVolatile(lhs.attrs.test(DummyDataObject::Attr::Volatile))
415 .Check(rhs);
416}
417
peter klausler4171f802020-06-19 00:17:04418bool CheckInitialTarget(evaluate::FoldingContext &context,
419 const SomeExpr &pointer, const SomeExpr &init) {
420 return evaluate::IsInitialDataTarget(init, &context.messages()) &&
421 CheckPointerAssignment(context, pointer, init);
422}
423
Tim Keith1f879002020-03-29 04:00:16424} // namespace Fortran::semantics