[flang-commits] [PATCH] D125342: [flang] Fix check for assumed-size arguments to SHAPE() & al.

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


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

The predicate that is used to detect an invalid assumed-size argument
to the intrinsic functions SHAPE, SIZE, & LBOUND gives false results
for arguments whose shapes are not calculatable at compilation time.
Replace with an explicit test for an assumed-size array dummy argument
symbol.


https://reviews.llvm.org/D125342

Files:
  flang/lib/Evaluate/intrinsics.cpp


Index: flang/lib/Evaluate/intrinsics.cpp
===================================================================
--- flang/lib/Evaluate/intrinsics.cpp
+++ flang/lib/Evaluate/intrinsics.cpp
@@ -1563,8 +1563,8 @@
           // (A previous error message for UBOUND will take precedence
           // over this one, as this error is caught by the second entry
           // for UBOUND.)
-          if (std::optional<Shape> shape{GetShape(context, *arg)}) {
-            if (!shape->empty() && !shape->back().has_value()) {
+          if (const Symbol * argSym{GetLastSymbol(*arg)}) {
+            if (semantics::IsAssumedSizeArray(*argSym)) {
               if (strcmp(name, "shape") == 0) {
                 messages.Say(arg->sourceLocation(),
                     "The '%s=' argument to the intrinsic function '%s' may not be assumed-size"_err_en_US,


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


More information about the flang-commits mailing list