[flang-commits] [PATCH] D125343: [flang] Allow local variables and function result inquiries in specification expressions

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue May 10 15:22:42 PDT 2022


klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

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.


https://reviews.llvm.org/D125343

Files:
  flang/lib/Evaluate/check-expression.cpp


Index: flang/lib/Evaluate/check-expression.cpp
===================================================================
--- flang/lib/Evaluate/check-expression.cpp
+++ flang/lib/Evaluate/check-expression.cpp
@@ -114,7 +114,8 @@
   // 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 @@
         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 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125343.428514.patch
Type: text/x-patch
Size: 1094 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220510/b6396f84/attachment.bin>


More information about the flang-commits mailing list