llvm-project/flang/test/Evaluate
Jean Perier fb3faa8b32 [flang] Do not lose call in shape inquiry on function reference
Currently, something like `print *, size(foo(n,m))` was rewritten
to `print *, size(foo_result_symbol)` when foo result is a non constant
shape array. This cannot be processed by lowering or reprocessed by a
Fortran compiler since the syntax is wrong (`foo_result_symbol` is
unknown on the caller side) and the arguments are lost when they might
be required to compute the result shape.

It is not possible (and probably not desired) to make GetShape fail in
general in such case since returning nullopt seems only expected for
scalars or assumed rank (see GetRank usage in lib/Semantics/check-call.cpp),
and returning a vector with nullopt extent may trigger some checks to
believe they are facing an assumed size (like here in intrinsic argument
checks: 196204c72c/flang/lib/Evaluate/intrinsics.cpp (L1530)).

Hence, I went for a solution that limits the rewrite change to folding
(where the original expression is returned if the shape depends on a non
constant shape from a call).

I added a non default option to GetShapeHelper that prevents the rewrite
of shape inquiry on calls to descriptor inquiries. At first I wanted to
avoid touching GetShapeHelper, but it would require to re-implement all
its logic to determine if the shape comes from a function call or not
(the expression could be `size(1+foo(n,m))`). So added an alternate
entry point to GetShapeHelper seemed the cleanest solution to me.

Differential Revision: https://reviews.llvm.org/D116933
2022-01-10 19:10:48 +01:00
..
errors01.f90 [flang] Fold SPREAD 2021-10-28 14:10:16 -07:00
expr01.f90 [flang] Represent (parentheses around derived types) 2021-09-23 13:03:13 -07:00
fold-btest.f90 [flang] Fold BTEST 2021-10-18 13:46:46 -07:00
fold-char-cmp.f90 [flang] Fold LGE/LGT/LLE/LLT intrinsic functions 2021-10-14 15:24:03 -07:00
fold-findloc.f90 [flang] Fix combined folding of FINDLOC/MAXLOC/MINLOC 2021-10-29 11:00:11 -07:00
fold-ishft.f90 [flang] Fix bogus folding error for ISHFT(x, negative) 2021-10-22 10:38:27 -07:00
fold-spread.f90 [flang] Fold SPREAD 2021-10-28 14:10:16 -07:00
folding01.f90 [flang] Fix usage & catch errors for MAX/MIN with keyword= arguments 2021-11-30 12:53:47 -08:00
folding02.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding03.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding04.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding05.f90 [flang] Fold LGE/LGT/LLE/LLT intrinsic functions 2021-10-14 15:24:03 -07:00
folding06.f90 [flang] Fix ORDER= argument to RESHAPE 2021-11-12 10:25:00 -08:00
folding07.f90 [flang] Fix folding of EXPONENT() intrinsic function 2021-12-04 11:23:09 -08:00
folding08.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding09.f90 [flang] Return true in IsSymplyContiguous for allocatables 2021-11-29 08:28:26 +01:00
folding10.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding11.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding12.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding13.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding14.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding15.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding16.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding17.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding18.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding20.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding21.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding22.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding23.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding24.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding25.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding26.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding27.f90 [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00
folding28.f90 [flang] Fix test regression from SQRT folding 2021-09-30 11:35:44 -07:00
folding29.f90 [flang] Fold COUNT() 2021-09-16 17:09:23 -07:00
folding30.f90 [flang] Fix folding of ac-implied-do indices in structure c'tors 2021-12-09 18:03:04 -08:00
rewrite01.f90 [flang] Do not lose call in shape inquiry on function reference 2022-01-10 19:10:48 +01:00
test_folding.py [Flang] Port test_folding.sh to Python 2021-09-06 13:54:56 +00:00