[flang-commits] [PATCH] D140126: [flang] Correct folding of SAME_TYPE_AS()

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Dec 15 10:53:52 PST 2022


klausler created this revision.
klausler added a reviewer: clementval.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

The result can't be known to be true at compilation time when
either operand is polymorphic.


https://reviews.llvm.org/D140126

Files:
  flang/lib/Evaluate/type.cpp


Index: flang/lib/Evaluate/type.cpp
===================================================================
--- flang/lib/Evaluate/type.cpp
+++ flang/lib/Evaluate/type.cpp
@@ -354,10 +354,11 @@
 std::optional<bool> DynamicType::SameTypeAs(const DynamicType &that) const {
   bool x{AreCompatibleTypes(*this, that, true, true)};
   bool y{AreCompatibleTypes(that, *this, true, true)};
-  if (x == y) {
-    return x;
+  if (!x && !y) {
+    return false;
+  } else if (x && y && !IsPolymorphic() && !that.IsPolymorphic()) {
+    return true;
   } else {
-    // If either is unlimited polymorphic, the result is unknown.
     return std::nullopt;
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140126.483241.patch
Type: text/x-patch
Size: 649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221215/ac66b3bd/attachment.bin>


More information about the flang-commits mailing list