[flang-commits] [flang] 2cd9550 - [flang] Allow local variables and function result inquiries in specification expressions
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Tue May 10 16:47:12 PDT 2022
Author: Peter Klausler
Date: 2022-05-10T16:47:03-07:00
New Revision: 2cd95504df575d129b0c23327962695d47dc25fd
URL: https://github.com/llvm/llvm-project/commit/2cd95504df575d129b0c23327962695d47dc25fd
DIFF: https://github.com/llvm/llvm-project/commit/2cd95504df575d129b0c23327962695d47dc25fd.diff
LOG: [flang] Allow local variables and function result inquiries in specification expressions
Inquiries into the bounds, size, and length of local variables (and function results)
are acceptable specification expressions. A recent change allowed them for dummy
arguments that are not OPTIONAL or INTENT(OUT), but didn't address other object
entities.
Differential Revision: https://reviews.llvm.org/D125343
Added:
Modified:
flang/lib/Evaluate/check-expression.cpp
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/check-expression.cpp b/flang/lib/Evaluate/check-expression.cpp
index 13b48a2cd2e8f..789e0a2de7d2e 100644
--- a/flang/lib/Evaluate/check-expression.cpp
+++ b/flang/lib/Evaluate/check-expression.cpp
@@ -114,7 +114,8 @@ bool IsConstantExprHelper<INVARIANT>::operator()(
// been rewritten into DescriptorInquiry operations.
if (const auto *intrinsic{std::get_if<SpecificIntrinsic>(&call.proc().u)}) {
if (intrinsic->name == "kind" ||
- intrinsic->name == IntrinsicProcTable::InvalidName) {
+ intrinsic->name == IntrinsicProcTable::InvalidName ||
+ call.arguments().empty() || !call.arguments()[0]) {
// kind is always a constant, and we avoid cascading errors by considering
// invalid calls to intrinsics to be constant
return true;
@@ -539,7 +540,11 @@ class CheckSpecificationExprHelper
return std::nullopt;
}
}
- return "reference to local entity '"s + ultimate.name().ToString() + "'";
+ if (inInquiry_) {
+ return std::nullopt;
+ } else {
+ return "reference to local entity '"s + ultimate.name().ToString() + "'";
+ }
}
Result operator()(const Component &x) const {
More information about the flang-commits
mailing list