[flang] add attribute to trim runtime implementation establish call
authorJean Perier <jperier@nvidia.com>
Wed, 24 Feb 2021 17:53:03 +0000 (18:53 +0100)
committerJean Perier <jperier@nvidia.com>
Wed, 24 Feb 2021 17:53:55 +0000 (18:53 +0100)
CFI allocatable attribute is needed so that the descriptor for the
result can be allocated/deallocated.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D97395

flang/runtime/character.cpp

index c241afd..9476bde 100644 (file)
@@ -686,7 +686,8 @@ void RTNAME(Trim)(Descriptor &result, const Descriptor &string,
     terminator.Crash(
         "TRIM: bad string type code %d", static_cast<int>(string.raw().type));
   }
-  result.Establish(string.type(), resultBytes, nullptr, 0);
+  result.Establish(string.type(), resultBytes, nullptr, 0, nullptr,
+      CFI_attribute_allocatable);
   RUNTIME_CHECK(terminator, result.Allocate(nullptr, nullptr) == CFI_SUCCESS);
   std::memcpy(result.OffsetElement(), string.OffsetElement(), resultBytes);
 }