[PATCH] D99892: [flang] Improve constant folding for type parameter inquiries
Peter Klausler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 5 11:38:36 PDT 2021
klausler 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
----------------
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.
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