[flang-commits] [PATCH] D130383: [flang] Don't fold zero-length substring references

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Sat Jul 23 10:08:35 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG3096b85696cc: [flang] Don't fold zero-length substring references (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130383/new/

https://reviews.llvm.org/D130383

Files:
  flang/lib/Evaluate/fold-implementation.h


Index: flang/lib/Evaluate/fold-implementation.h
===================================================================
--- flang/lib/Evaluate/fold-implementation.h
+++ flang/lib/Evaluate/fold-implementation.h
@@ -342,11 +342,9 @@
           return std::move(*specific);
         }
       }
-      if (auto length{ToInt64(Fold(context_, substring->LEN()))}) {
-        if (*length == 0) {
-          return Expr<T>{Constant<T>{Scalar<T>{}}};
-        }
-      }
+      // We used to fold zero-length substrings into zero-length
+      // constants here, but that led to problems in variable
+      // definition contexts.
     }
   } else if constexpr (T::category == TypeCategory::Real) {
     if (auto *zPart{std::get_if<ComplexPart>(&designator.u)}) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130383.447083.patch
Type: text/x-patch
Size: 751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220723/4a05e5ba/attachment.bin>


More information about the flang-commits mailing list