[flang] Fix an assert when RESHAPE() is called on empty strings
authorPete Steinfeld <psteinfeld@nvidia.com>
Wed, 22 Jul 2020 18:33:35 +0000 (11:33 -0700)
committerPete Steinfeld <psteinfeld@nvidia.com>
Wed, 22 Jul 2020 19:21:58 +0000 (12:21 -0700)
commitf72106e2a35b12ef4bb265e755a6ee33a576c768
treeab275f1cf1ffb6d8d66c475bb352520d90f09577
parentbcbc6117b5d944bca8519dd34131cda1e83789fe
[flang] Fix an assert when RESHAPE() is called on empty strings

Summary:
When a constant array of empty strings goes through contant folding, the result
is something that contains no bytes.  If this array is passed to the intrinsic
function `RESHAPE()`, we were not handling things correctly.  I fixed this by
checking for an empty destination when calling the function `CopyFrom()` on an
array of strings.

I also added a test with a couple of different examples that trigger the
problem.

Reviewers: klausler, tskeith, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D84352
flang/lib/Evaluate/constant.cpp
flang/test/Semantics/modfile25.f90