[flang] Trim duplicate error messages on intrinsics, and fix FINDLOC for Character...
authorpeter klausler <pklausler@nvidia.com>
Wed, 3 Jul 2019 19:19:35 +0000 (12:19 -0700)
committerpeter klausler <pklausler@nvidia.com>
Wed, 3 Jul 2019 19:30:28 +0000 (12:30 -0700)
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
flang/lib/parser/message.cc
flang/lib/parser/message.h

index 4c96170..c5346bc 100644 (file)
@@ -1006,7 +1006,7 @@ std::optional<SpecificCall> 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<SpecificCall> 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<SpecificCall> 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<SpecificCall> 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<SpecificCall> 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();
         }
       }
     }
index 117fbc2..6096f66 100644 (file)
@@ -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_) {
index 49e8d0f..81dc88c 100644 (file)
@@ -237,6 +237,7 @@ public:
   }
 
   bool empty() const { return messages_.empty(); }
+  void clear();
 
   template<typename... A> Message &Say(A &&... args) {
     last_ = messages_.emplace_after(last_, std::forward<A>(args)...);