From c180c0229fe9eaa0d8cc02084f63d78cb6824aa9 Mon Sep 17 00:00:00 2001 From: peter klausler Date: Wed, 3 Jul 2019 12:19:35 -0700 Subject: [PATCH] [flang] Trim duplicate error messages on intrinsics, and fix FINDLOC for Character data. Original-commit: flang-compiler/f18@48ab22e2130994653c5585cb290512543a3f599f Reviewed-on: https://github.com/flang-compiler/f18/pull/548 Tree-same-pre-rewrite: false --- flang/lib/evaluate/intrinsics.cc | 12 +++++++----- flang/lib/parser/message.cc | 5 +++++ flang/lib/parser/message.h | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/flang/lib/evaluate/intrinsics.cc b/flang/lib/evaluate/intrinsics.cc index 4c96170..c5346bc 100644 --- a/flang/lib/evaluate/intrinsics.cc +++ b/flang/lib/evaluate/intrinsics.cc @@ -1006,7 +1006,7 @@ std::optional IntrinsicInterface::Match( if (sameArg == nullptr) { sameArg = arg; } - argOk = type.value() == sameArg->GetType(); + argOk = type->IsTkCompatibleWith(sameArg->GetType().value()); break; case KindCode::effectiveKind: common::die("INTERNAL: KindCode::effectiveKind appears on argument '%s' " @@ -1523,7 +1523,6 @@ std::optional IntrinsicProcTable::Implementation::Probe( parser::Messages genericBuffer; auto genericRange{genericFuncs_.equal_range(name)}; for (auto iter{genericRange.first}; iter != genericRange.second; ++iter) { - CHECK(localBuffer.empty()); if (auto specificCall{ iter->second->Match(call, defaults_, arguments, localContext)}) { ApplySpecificChecks(*specificCall, localMessages); @@ -1531,8 +1530,10 @@ std::optional IntrinsicProcTable::Implementation::Probe( finalBuffer->Annex(std::move(localBuffer)); } return specificCall; - } else { + } else if (genericBuffer.empty()) { genericBuffer.Annex(std::move(localBuffer)); + } else { + localBuffer.clear(); } } // Probe the specific intrinsic function table next. @@ -1546,7 +1547,6 @@ std::optional IntrinsicProcTable::Implementation::Probe( auto genericRange{genericFuncs_.equal_range(genericName)}; for (auto genIter{genericRange.first}; genIter != genericRange.second; ++genIter) { - CHECK(localBuffer.empty()); if (auto specificCall{genIter->second->Match( call, defaults_, arguments, localContext)}) { specificCall->specificIntrinsic.name = genericName; @@ -1573,8 +1573,10 @@ std::optional IntrinsicProcTable::Implementation::Probe( // TODO test feature AdditionalIntrinsics, warn on nonstandard // specifics with DoublePrecisionComplex arguments. return specificCall; - } else { + } else if (specificBuffer.empty()) { specificBuffer.Annex(std::move(localBuffer)); + } else { + specificBuffer.clear(); } } } diff --git a/flang/lib/parser/message.cc b/flang/lib/parser/message.cc index 117fbc2..6096f66 100644 --- a/flang/lib/parser/message.cc +++ b/flang/lib/parser/message.cc @@ -270,6 +270,11 @@ bool Message::AtSameLocation(const Message &that) const { location_, that.location_); } +void Messages::clear() { + messages_.clear(); + ResetLastPointer(); +} + bool Messages::Merge(const Message &msg) { if (msg.IsMergeable()) { for (auto &m : messages_) { diff --git a/flang/lib/parser/message.h b/flang/lib/parser/message.h index 49e8d0f..81dc88c 100644 --- a/flang/lib/parser/message.h +++ b/flang/lib/parser/message.h @@ -237,6 +237,7 @@ public: } bool empty() const { return messages_.empty(); } + void clear(); template Message &Say(A &&... args) { last_ = messages_.emplace_after(last_, std::forward(args)...); -- 2.7.4