1 //===-- lib/Evaluate/variable.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 "flang/Evaluate/variable.h" 10 #include "flang/Common/idioms.h" 11 #include "flang/Evaluate/check-expression.h" 12 #include "flang/Evaluate/fold.h" 13 #include "flang/Evaluate/tools.h" 14 #include "flang/Parser/char-block.h" 15 #include "flang/Parser/characters.h" 16 #include "flang/Parser/message.h" 17 #include "flang/Semantics/scope.h" 18 #include "flang/Semantics/symbol.h" 19 #include <type_traits> 20 21 using namespace Fortran::parser::literals; 22 23 namespace Fortran::evaluate { 24 25 // Constructors, accessors, mutators 26 27 Triplet::Triplet() : stride_{Expr<SubscriptInteger>{1}} {} 28 29 Triplet::Triplet(std::optional<Expr<SubscriptInteger>> &&l, 30 std::optional<Expr<SubscriptInteger>> &&u, 31 std::optional<Expr<SubscriptInteger>> &&s) 32 : stride_{s ? std::move(*s) : Expr<SubscriptInteger>{1}} { 33 if (l) { 34 lower_.emplace(std::move(*l)); 35 } 36 if (u) { 37 upper_.emplace(std::move(*u)); 38 } 39 } 40 41 std::optional<Expr<SubscriptInteger>> Triplet::lower() const { 42 if (lower_) { 43 return {lower_.value().value()}; 44 } 45 return std::nullopt; 46 } 47 48 Triplet &Triplet::set_lower(Expr<SubscriptInteger> &&expr) { 49 lower_.emplace(std::move(expr)); 50 return *this; 51 } 52 53 std::optional<Expr<SubscriptInteger>> Triplet::upper() const { 54 if (upper_) { 55 return {upper_.value().value()}; 56 } 57 return std::nullopt; 58 } 59 60 Triplet &Triplet::set_upper(Expr<SubscriptInteger> &&expr) { 61 upper_.emplace(std::move(expr)); 62 return *this; 63 } 64 65 Expr<SubscriptInteger> Triplet::stride() const { return stride_.value(); } 66 67 Triplet &Triplet::set_stride(Expr<SubscriptInteger> &&expr) { 68 stride_.value() = std::move(expr); 69 return *this; 70 } 71 72 CoarrayRef::CoarrayRef(SymbolVector &&base, std::vector<Subscript> &&ss, 73 std::vector<Expr<SubscriptInteger>> &&css) 74 : base_{std::move(base)}, subscript_(std::move(ss)), 75 cosubscript_(std::move(css)) { 76 CHECK(!base_.empty()); 77 CHECK(!cosubscript_.empty()); 78 } 79 80 std::optional<Expr<SomeInteger>> CoarrayRef::stat() const { 81 if (stat_) { 82 return stat_.value().value(); 83 } else { 84 return std::nullopt; 85 } 86 } 87 88 std::optional<Expr<SomeInteger>> CoarrayRef::team() const { 89 if (team_) { 90 return team_.value().value(); 91 } else { 92 return std::nullopt; 93 } 94 } 95 96 CoarrayRef &CoarrayRef::set_stat(Expr<SomeInteger> &&v) { 97 CHECK(IsVariable(v)); 98 stat_.emplace(std::move(v)); 99 return *this; 100 } 101 102 CoarrayRef &CoarrayRef::set_team(Expr<SomeInteger> &&v, bool isTeamNumber) { 103 CHECK(IsVariable(v)); 104 team_.emplace(std::move(v)); 105 teamIsTeamNumber_ = isTeamNumber; 106 return *this; 107 } 108 109 const Symbol &CoarrayRef::GetFirstSymbol() const { return base_.front(); } 110 111 const Symbol &CoarrayRef::GetLastSymbol() const { return base_.back(); } 112 113 void Substring::SetBounds(std::optional<Expr<SubscriptInteger>> &lower, 114 std::optional<Expr<SubscriptInteger>> &upper) { 115 if (lower) { 116 set_lower(std::move(lower.value())); 117 } 118 if (upper) { 119 set_upper(std::move(upper.value())); 120 } 121 } 122 123 Expr<SubscriptInteger> Substring::lower() const { 124 if (lower_) { 125 return lower_.value().value(); 126 } else { 127 return AsExpr(Constant<SubscriptInteger>{1}); 128 } 129 } 130 131 Substring &Substring::set_lower(Expr<SubscriptInteger> &&expr) { 132 lower_.emplace(std::move(expr)); 133 return *this; 134 } 135 136 std::optional<Expr<SubscriptInteger>> Substring::upper() const { 137 if (upper_) { 138 return upper_.value().value(); 139 } else { 140 return common::visit( 141 common::visitors{ 142 [](const DataRef &dataRef) { return dataRef.LEN(); }, 143 [](const StaticDataObject::Pointer &object) 144 -> std::optional<Expr<SubscriptInteger>> { 145 return AsExpr(Constant<SubscriptInteger>{object->data().size()}); 146 }, 147 }, 148 parent_); 149 } 150 } 151 152 Substring &Substring::set_upper(Expr<SubscriptInteger> &&expr) { 153 upper_.emplace(std::move(expr)); 154 return *this; 155 } 156 157 std::optional<Expr<SomeCharacter>> Substring::Fold(FoldingContext &context) { 158 if (!upper_) { 159 upper_ = upper(); 160 if (!upper_) { 161 return std::nullopt; 162 } 163 } 164 upper_.value() = evaluate::Fold(context, std::move(upper_.value().value())); 165 std::optional<ConstantSubscript> ubi{ToInt64(upper_.value().value())}; 166 if (!ubi) { 167 return std::nullopt; 168 } 169 if (!lower_) { 170 lower_ = AsExpr(Constant<SubscriptInteger>{1}); 171 } 172 lower_.value() = evaluate::Fold(context, std::move(lower_.value().value())); 173 std::optional<ConstantSubscript> lbi{ToInt64(lower_.value().value())}; 174 if (!lbi) { 175 return std::nullopt; 176 } 177 if (*lbi > *ubi) { // empty result; canonicalize 178 *lbi = 1; 179 *ubi = 0; 180 lower_ = AsExpr(Constant<SubscriptInteger>{*lbi}); 181 upper_ = AsExpr(Constant<SubscriptInteger>{*ubi}); 182 } 183 std::optional<ConstantSubscript> length; 184 std::optional<Expr<SomeCharacter>> strings; // a Constant<Character> 185 if (const auto *literal{std::get_if<StaticDataObject::Pointer>(&parent_)}) { 186 length = (*literal)->data().size(); 187 if (auto str{(*literal)->AsString()}) { 188 strings = 189 Expr<SomeCharacter>(Expr<Ascii>(Constant<Ascii>{std::move(*str)})); 190 } 191 } else if (const auto *dataRef{std::get_if<DataRef>(&parent_)}) { 192 if (auto expr{AsGenericExpr(DataRef{*dataRef})}) { 193 auto folded{evaluate::Fold(context, std::move(*expr))}; 194 if (IsActuallyConstant(folded)) { 195 if (const auto *value{UnwrapExpr<Expr<SomeCharacter>>(folded)}) { 196 strings = *value; 197 } 198 } 199 } 200 } 201 std::optional<Expr<SomeCharacter>> result; 202 if (strings) { 203 result = common::visit( 204 [&](const auto &expr) -> std::optional<Expr<SomeCharacter>> { 205 using Type = typename std::decay_t<decltype(expr)>::Result; 206 if (const auto *cc{std::get_if<Constant<Type>>(&expr.u)}) { 207 if (auto substr{cc->Substring(*lbi, *ubi)}) { 208 return Expr<SomeCharacter>{Expr<Type>{*substr}}; 209 } 210 } 211 return std::nullopt; 212 }, 213 strings->u); 214 } 215 if (!result) { // error cases 216 if (*lbi < 1) { 217 if (context.languageFeatures().ShouldWarn(common::UsageWarning::Bounds)) { 218 context.messages().Say( 219 "Lower bound (%jd) on substring is less than one"_warn_en_US, 220 static_cast<std::intmax_t>(*lbi)); 221 } 222 *lbi = 1; 223 lower_ = AsExpr(Constant<SubscriptInteger>{1}); 224 } 225 if (length && *ubi > *length) { 226 if (context.languageFeatures().ShouldWarn(common::UsageWarning::Bounds)) { 227 context.messages().Say( 228 "Upper bound (%jd) on substring is greater than character length (%jd)"_warn_en_US, 229 static_cast<std::intmax_t>(*ubi), 230 static_cast<std::intmax_t>(*length)); 231 } 232 *ubi = *length; 233 upper_ = AsExpr(Constant<SubscriptInteger>{*ubi}); 234 } 235 } 236 return result; 237 } 238 239 DescriptorInquiry::DescriptorInquiry( 240 const NamedEntity &base, Field field, int dim) 241 : base_{base}, field_{field}, dimension_{dim} { 242 const Symbol &last{base_.GetLastSymbol()}; 243 CHECK(IsDescriptor(last)); 244 CHECK(((field == Field::Len || field == Field::Rank) && dim == 0) || 245 (field != Field::Len && dim >= 0 && dim < last.Rank())); 246 } 247 248 DescriptorInquiry::DescriptorInquiry(NamedEntity &&base, Field field, int dim) 249 : base_{std::move(base)}, field_{field}, dimension_{dim} { 250 const Symbol &last{base_.GetLastSymbol()}; 251 CHECK(IsDescriptor(last)); 252 CHECK((field == Field::Len && dim == 0) || 253 (field != Field::Len && dim >= 0 && 254 (dim < last.Rank() || IsAssumedRank(last)))); 255 } 256 257 // LEN() 258 static std::optional<Expr<SubscriptInteger>> SymbolLEN(const Symbol &symbol) { 259 const Symbol &ultimate{symbol.GetUltimate()}; 260 if (const auto *assoc{ultimate.detailsIf<semantics::AssocEntityDetails>()}) { 261 if (const auto *chExpr{UnwrapExpr<Expr<SomeCharacter>>(assoc->expr())}) { 262 return chExpr->LEN(); 263 } 264 } 265 if (auto dyType{DynamicType::From(ultimate)}) { 266 auto len{dyType->GetCharLength()}; 267 if (!len && ultimate.attrs().test(semantics::Attr::PARAMETER)) { 268 // Its initializer determines the length of an implied-length named 269 // constant. 270 if (const auto *object{ 271 ultimate.detailsIf<semantics::ObjectEntityDetails>()}) { 272 if (object->init()) { 273 if (auto dyType2{DynamicType::From(*object->init())}) { 274 len = dyType2->GetCharLength(); 275 } 276 } 277 } 278 } 279 if (len) { 280 if (auto constLen{ToInt64(*len)}) { 281 return Expr<SubscriptInteger>{std::max<std::int64_t>(*constLen, 0)}; 282 } else if (ultimate.owner().IsDerivedType() || 283 IsScopeInvariantExpr(*len)) { 284 return AsExpr(Extremum<SubscriptInteger>{ 285 Ordering::Greater, Expr<SubscriptInteger>{0}, std::move(*len)}); 286 } 287 } 288 } 289 if (IsDescriptor(ultimate) && !ultimate.owner().IsDerivedType()) { 290 return Expr<SubscriptInteger>{ 291 DescriptorInquiry{NamedEntity{symbol}, DescriptorInquiry::Field::Len}}; 292 } 293 return std::nullopt; 294 } 295 296 std::optional<Expr<SubscriptInteger>> BaseObject::LEN() const { 297 return common::visit( 298 common::visitors{ 299 [](const Symbol &symbol) { return SymbolLEN(symbol); }, 300 [](const StaticDataObject::Pointer &object) 301 -> std::optional<Expr<SubscriptInteger>> { 302 return AsExpr(Constant<SubscriptInteger>{object->data().size()}); 303 }, 304 }, 305 u); 306 } 307 308 std::optional<Expr<SubscriptInteger>> Component::LEN() const { 309 return SymbolLEN(GetLastSymbol()); 310 } 311 312 std::optional<Expr<SubscriptInteger>> NamedEntity::LEN() const { 313 return SymbolLEN(GetLastSymbol()); 314 } 315 316 std::optional<Expr<SubscriptInteger>> ArrayRef::LEN() const { 317 return base_.LEN(); 318 } 319 320 std::optional<Expr<SubscriptInteger>> CoarrayRef::LEN() const { 321 return SymbolLEN(GetLastSymbol()); 322 } 323 324 std::optional<Expr<SubscriptInteger>> DataRef::LEN() const { 325 return common::visit(common::visitors{ 326 [](SymbolRef symbol) { return SymbolLEN(symbol); }, 327 [](const auto &x) { return x.LEN(); }, 328 }, 329 u); 330 } 331 332 std::optional<Expr<SubscriptInteger>> Substring::LEN() const { 333 if (auto top{upper()}) { 334 return AsExpr(Extremum<SubscriptInteger>{Ordering::Greater, 335 AsExpr(Constant<SubscriptInteger>{0}), 336 *std::move(top) - lower() + AsExpr(Constant<SubscriptInteger>{1})}); 337 } else { 338 return std::nullopt; 339 } 340 } 341 342 template <typename T> 343 std::optional<Expr<SubscriptInteger>> Designator<T>::LEN() const { 344 if constexpr (T::category == TypeCategory::Character) { 345 return common::visit(common::visitors{ 346 [](SymbolRef symbol) { return SymbolLEN(symbol); }, 347 [](const auto &x) { return x.LEN(); }, 348 }, 349 u); 350 } else { 351 common::die("Designator<non-char>::LEN() called"); 352 return std::nullopt; 353 } 354 } 355 356 std::optional<Expr<SubscriptInteger>> ProcedureDesignator::LEN() const { 357 using T = std::optional<Expr<SubscriptInteger>>; 358 return common::visit( 359 common::visitors{ 360 [](SymbolRef symbol) -> T { return SymbolLEN(symbol); }, 361 [](const common::CopyableIndirection<Component> &c) -> T { 362 return c.value().LEN(); 363 }, 364 [](const SpecificIntrinsic &i) -> T { 365 // Some cases whose results' lengths can be determined 366 // from the lengths of their arguments are handled in 367 // ProcedureRef::LEN() before coming here. 368 if (const auto &result{i.characteristics.value().functionResult}) { 369 if (const auto *type{result->GetTypeAndShape()}) { 370 if (auto length{type->type().GetCharLength()}) { 371 return std::move(*length); 372 } 373 } 374 } 375 return std::nullopt; 376 }, 377 }, 378 u); 379 } 380 381 // Rank() 382 int BaseObject::Rank() const { 383 return common::visit(common::visitors{ 384 [](SymbolRef symbol) { return symbol->Rank(); }, 385 [](const StaticDataObject::Pointer &) { return 0; }, 386 }, 387 u); 388 } 389 390 int Component::Rank() const { 391 if (int rank{symbol_->Rank()}; rank > 0) { 392 return rank; 393 } 394 return base().Rank(); 395 } 396 397 int NamedEntity::Rank() const { 398 return common::visit(common::visitors{ 399 [](const SymbolRef s) { return s->Rank(); }, 400 [](const Component &c) { return c.Rank(); }, 401 }, 402 u_); 403 } 404 405 int Subscript::Rank() const { 406 return common::visit(common::visitors{ 407 [](const IndirectSubscriptIntegerExpr &x) { 408 return x.value().Rank(); 409 }, 410 [](const Triplet &) { return 1; }, 411 }, 412 u); 413 } 414 415 int ArrayRef::Rank() const { 416 int rank{0}; 417 for (const auto &expr : subscript_) { 418 rank += expr.Rank(); 419 } 420 if (rank > 0) { 421 return rank; 422 } else if (const Component * component{base_.UnwrapComponent()}) { 423 return component->base().Rank(); 424 } else { 425 return 0; 426 } 427 } 428 429 int CoarrayRef::Rank() const { 430 if (!subscript_.empty()) { 431 int rank{0}; 432 for (const auto &expr : subscript_) { 433 rank += expr.Rank(); 434 } 435 return rank; 436 } else { 437 return base_.back()->Rank(); 438 } 439 } 440 441 int DataRef::Rank() const { 442 return common::visit(common::visitors{ 443 [](SymbolRef symbol) { return symbol->Rank(); }, 444 [](const auto &x) { return x.Rank(); }, 445 }, 446 u); 447 } 448 449 int Substring::Rank() const { 450 return common::visit( 451 common::visitors{ 452 [](const DataRef &dataRef) { return dataRef.Rank(); }, 453 [](const StaticDataObject::Pointer &) { return 0; }, 454 }, 455 parent_); 456 } 457 458 int ComplexPart::Rank() const { return complex_.Rank(); } 459 460 template <typename T> int Designator<T>::Rank() const { 461 return common::visit(common::visitors{ 462 [](SymbolRef symbol) { return symbol->Rank(); }, 463 [](const auto &x) { return x.Rank(); }, 464 }, 465 u); 466 } 467 468 // GetBaseObject(), GetFirstSymbol(), GetLastSymbol(), &c. 469 const Symbol &Component::GetFirstSymbol() const { 470 return base_.value().GetFirstSymbol(); 471 } 472 473 const Symbol &NamedEntity::GetFirstSymbol() const { 474 return common::visit(common::visitors{ 475 [](SymbolRef s) -> const Symbol & { return s; }, 476 [](const Component &c) -> const Symbol & { 477 return c.GetFirstSymbol(); 478 }, 479 }, 480 u_); 481 } 482 483 const Symbol &NamedEntity::GetLastSymbol() const { 484 return common::visit(common::visitors{ 485 [](SymbolRef s) -> const Symbol & { return s; }, 486 [](const Component &c) -> const Symbol & { 487 return c.GetLastSymbol(); 488 }, 489 }, 490 u_); 491 } 492 493 const SymbolRef *NamedEntity::UnwrapSymbolRef() const { 494 return common::visit( 495 common::visitors{ 496 [](const SymbolRef &s) { return &s; }, 497 [](const Component &) -> const SymbolRef * { return nullptr; }, 498 }, 499 u_); 500 } 501 502 SymbolRef *NamedEntity::UnwrapSymbolRef() { 503 return common::visit(common::visitors{ 504 [](SymbolRef &s) { return &s; }, 505 [](Component &) -> SymbolRef * { return nullptr; }, 506 }, 507 u_); 508 } 509 510 const Component *NamedEntity::UnwrapComponent() const { 511 return common::visit( 512 common::visitors{ 513 [](SymbolRef) -> const Component * { return nullptr; }, 514 [](const Component &c) { return &c; }, 515 }, 516 u_); 517 } 518 519 Component *NamedEntity::UnwrapComponent() { 520 return common::visit(common::visitors{ 521 [](SymbolRef &) -> Component * { return nullptr; }, 522 [](Component &c) { return &c; }, 523 }, 524 u_); 525 } 526 527 const Symbol &ArrayRef::GetFirstSymbol() const { 528 return base_.GetFirstSymbol(); 529 } 530 531 const Symbol &ArrayRef::GetLastSymbol() const { return base_.GetLastSymbol(); } 532 533 const Symbol &DataRef::GetFirstSymbol() const { 534 return *common::visit(common::visitors{ 535 [](SymbolRef symbol) { return &*symbol; }, 536 [](const auto &x) { return &x.GetFirstSymbol(); }, 537 }, 538 u); 539 } 540 541 const Symbol &DataRef::GetLastSymbol() const { 542 return *common::visit(common::visitors{ 543 [](SymbolRef symbol) { return &*symbol; }, 544 [](const auto &x) { return &x.GetLastSymbol(); }, 545 }, 546 u); 547 } 548 549 BaseObject Substring::GetBaseObject() const { 550 return common::visit(common::visitors{ 551 [](const DataRef &dataRef) { 552 return BaseObject{dataRef.GetFirstSymbol()}; 553 }, 554 [](StaticDataObject::Pointer pointer) { 555 return BaseObject{std::move(pointer)}; 556 }, 557 }, 558 parent_); 559 } 560 561 const Symbol *Substring::GetLastSymbol() const { 562 return common::visit( 563 common::visitors{ 564 [](const DataRef &dataRef) { return &dataRef.GetLastSymbol(); }, 565 [](const auto &) -> const Symbol * { return nullptr; }, 566 }, 567 parent_); 568 } 569 570 template <typename T> BaseObject Designator<T>::GetBaseObject() const { 571 return common::visit( 572 common::visitors{ 573 [](SymbolRef symbol) { return BaseObject{symbol}; }, 574 [](const Substring &sstring) { return sstring.GetBaseObject(); }, 575 [](const auto &x) { return BaseObject{x.GetFirstSymbol()}; }, 576 }, 577 u); 578 } 579 580 template <typename T> const Symbol *Designator<T>::GetLastSymbol() const { 581 return common::visit( 582 common::visitors{ 583 [](SymbolRef symbol) { return &*symbol; }, 584 [](const Substring &sstring) { return sstring.GetLastSymbol(); }, 585 [](const auto &x) { return &x.GetLastSymbol(); }, 586 }, 587 u); 588 } 589 590 template <typename T> 591 std::optional<DynamicType> Designator<T>::GetType() const { 592 if constexpr (IsLengthlessIntrinsicType<Result>) { 593 return Result::GetType(); 594 } 595 if constexpr (Result::category == TypeCategory::Character) { 596 if (std::holds_alternative<Substring>(u)) { 597 if (auto len{LEN()}) { 598 if (auto n{ToInt64(*len)}) { 599 return DynamicType{T::kind, *n}; 600 } 601 } 602 return DynamicType{TypeCategory::Character, T::kind}; 603 } 604 } 605 if (const Symbol * symbol{GetLastSymbol()}) { 606 return DynamicType::From(*symbol); 607 } 608 return std::nullopt; 609 } 610 611 static NamedEntity AsNamedEntity(const SymbolVector &x) { 612 CHECK(!x.empty()); 613 NamedEntity result{x.front()}; 614 int j{0}; 615 for (const Symbol &symbol : x) { 616 if (j++ != 0) { 617 DataRef base{result.IsSymbol() ? DataRef{result.GetLastSymbol()} 618 : DataRef{result.GetComponent()}}; 619 result = NamedEntity{Component{std::move(base), symbol}}; 620 } 621 } 622 return result; 623 } 624 625 NamedEntity CoarrayRef::GetBase() const { return AsNamedEntity(base_); } 626 627 // Equality testing 628 629 // For the purposes of comparing type parameter expressions while 630 // testing the compatibility of procedure characteristics, two 631 // dummy arguments with the same position are considered equal. 632 static std::optional<int> GetDummyArgPosition(const Symbol &original) { 633 const Symbol &symbol(original.GetUltimate()); 634 if (IsDummy(symbol)) { 635 if (const Symbol * proc{symbol.owner().symbol()}) { 636 if (const auto *subp{proc->detailsIf<semantics::SubprogramDetails>()}) { 637 int j{0}; 638 for (const Symbol *arg : subp->dummyArgs()) { 639 if (arg == &symbol) { 640 return j; 641 } 642 ++j; 643 } 644 } 645 } 646 } 647 return std::nullopt; 648 } 649 650 static bool AreSameSymbol(const Symbol &x, const Symbol &y) { 651 if (&x == &y) { 652 return true; 653 } 654 if (auto xPos{GetDummyArgPosition(x)}) { 655 if (auto yPos{GetDummyArgPosition(y)}) { 656 return *xPos == *yPos; 657 } 658 } 659 return false; 660 } 661 662 // Implements operator==() for a union type, using special case handling 663 // for Symbol references. 664 template <typename A> static bool TestVariableEquality(const A &x, const A &y) { 665 const SymbolRef *xSymbol{std::get_if<SymbolRef>(&x.u)}; 666 if (const SymbolRef * ySymbol{std::get_if<SymbolRef>(&y.u)}) { 667 return xSymbol && AreSameSymbol(*xSymbol, *ySymbol); 668 } else { 669 return x.u == y.u; 670 } 671 } 672 673 bool BaseObject::operator==(const BaseObject &that) const { 674 return TestVariableEquality(*this, that); 675 } 676 bool Component::operator==(const Component &that) const { 677 return base_ == that.base_ && &*symbol_ == &*that.symbol_; 678 } 679 bool NamedEntity::operator==(const NamedEntity &that) const { 680 if (IsSymbol()) { 681 return that.IsSymbol() && 682 AreSameSymbol(GetFirstSymbol(), that.GetFirstSymbol()); 683 } else { 684 return !that.IsSymbol() && GetComponent() == that.GetComponent(); 685 } 686 } 687 bool TypeParamInquiry::operator==(const TypeParamInquiry &that) const { 688 return &*parameter_ == &*that.parameter_ && base_ == that.base_; 689 } 690 bool Triplet::operator==(const Triplet &that) const { 691 return lower_ == that.lower_ && upper_ == that.upper_ && 692 stride_ == that.stride_; 693 } 694 bool Subscript::operator==(const Subscript &that) const { return u == that.u; } 695 bool ArrayRef::operator==(const ArrayRef &that) const { 696 return base_ == that.base_ && subscript_ == that.subscript_; 697 } 698 bool CoarrayRef::operator==(const CoarrayRef &that) const { 699 return base_ == that.base_ && subscript_ == that.subscript_ && 700 cosubscript_ == that.cosubscript_ && stat_ == that.stat_ && 701 team_ == that.team_ && teamIsTeamNumber_ == that.teamIsTeamNumber_; 702 } 703 bool DataRef::operator==(const DataRef &that) const { 704 return TestVariableEquality(*this, that); 705 } 706 bool Substring::operator==(const Substring &that) const { 707 return parent_ == that.parent_ && lower_ == that.lower_ && 708 upper_ == that.upper_; 709 } 710 bool ComplexPart::operator==(const ComplexPart &that) const { 711 return part_ == that.part_ && complex_ == that.complex_; 712 } 713 bool ProcedureRef::operator==(const ProcedureRef &that) const { 714 return proc_ == that.proc_ && arguments_ == that.arguments_; 715 } 716 template <typename T> 717 bool Designator<T>::operator==(const Designator<T> &that) const { 718 return TestVariableEquality(*this, that); 719 } 720 bool DescriptorInquiry::operator==(const DescriptorInquiry &that) const { 721 return field_ == that.field_ && base_ == that.base_ && 722 dimension_ == that.dimension_; 723 } 724 725 #ifdef _MSC_VER // disable bogus warning about missing definitions 726 #pragma warning(disable : 4661) 727 #endif 728 INSTANTIATE_VARIABLE_TEMPLATES 729 } // namespace Fortran::evaluate 730 731 template class Fortran::common::Indirection<Fortran::evaluate::Component, true>; 732