[PATCH] D99892: [flang] Improve constant folding for type parameter inquiries
Pete Steinfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 5 15:09:21 PDT 2021
PeteSteinfeld added inline comments.
================
Comment at: flang/lib/Evaluate/fold-integer.cpp:664
+ if (base) {
+ // Handling "designator%typeParam". Get the value of the type parameter
+ // from the instantiation of the base
----------------
klausler wrote:
> LEN type parameter inquiries are not safe to fold in all cases; the actual LEN parameter expression may not be constant. Consider
>
> subroutine foo(n)
> type :: t(len)
> integer, len :: len
> end type t
> type(t(n)) :: x
> n = n + 1
> print *, x%len
> end
>
> The value of x%len at its point of use needs to return the original value of the dummy argument, not its later updated value.
>
> In general, folding type parameter inquiries can be done only for KIND= parameters and for LEN= parameters whose expressions are constant expressions.
D'oh! I had intended for this new code to be specific to constant expressions, and I just realized that I didn't test for that. Stay tuned for an update.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99892/new/
https://reviews.llvm.org/D99892
More information about the llvm-commits
mailing list