[flang] Preserve useResultSymbolShape_ option when folding array constructor shape
authorJean Perier <jperier@nvidia.com>
Fri, 24 Feb 2023 08:06:14 +0000 (09:06 +0100)
committerJean Perier <jperier@nvidia.com>
Fri, 24 Feb 2023 08:06:30 +0000 (09:06 +0100)
commit91bd4c6e81ac8aebf1089eb52b935484925f2f58
tree138de571e1388c4752fbf146d2fbf86bc43f2e3d
parent0630bd6c300ba46d226ef84cd26c38f67bdfbb54
[flang] Preserve useResultSymbolShape_ option when folding array constructor shape

By default evaluate::GetShape(expr) may return a compiler generated expression
using symbols that are part of function interfaces if there are function
references in "expr".
It is not right to replace an inquiry of "expr" with such compiler
generated expression since the call context would be lost, along with
the meaning of the inquiry expression.
Inquiry folding uses GetContextFreeShape(expr) that sets-up
useResultSymbolShape_ in GetShapeHelper to prevent such bad rewrites. But this did not
work properly with array constructor: GetShapeHelper made a call to
GetShape, ignoring and losing the "useResultSymbolShape_" instruction.

Differential Revision: https://reviews.llvm.org/D144512
flang/include/flang/Evaluate/shape.h
flang/test/Evaluate/rewrite01.f90