[flang-commits] [PATCH] D128391: [flang] Fix bogus errors from SIZE/SHAPE/UBOUND on assumed-shape

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Jun 23 10:32:48 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb6fce8b92df5: [flang] Fix bogus errors from SIZE/SHAPE/UBOUND on assumed-shape (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128391/new/

https://reviews.llvm.org/D128391

Files:
  flang/include/flang/Evaluate/tools.h
  flang/lib/Evaluate/intrinsics.cpp
  flang/test/Semantics/misc-intrinsics.f90


Index: flang/test/Semantics/misc-intrinsics.f90
===================================================================
--- flang/test/Semantics/misc-intrinsics.f90
+++ flang/test/Semantics/misc-intrinsics.f90
@@ -19,5 +19,8 @@
     print *, size(array)
     print *, ubound(array)
     print *, lbound(array)
+    print *, size(arg(:,1))
+    print *, ubound(arg(:,1))
+    print *, shape(arg(:,1))
   end subroutine
 end
Index: flang/lib/Evaluate/intrinsics.cpp
===================================================================
--- flang/lib/Evaluate/intrinsics.cpp
+++ flang/lib/Evaluate/intrinsics.cpp
@@ -1561,14 +1561,14 @@
             (std::strcmp(name, "shape") == 0 ||
                 std::strcmp(name, "size") == 0 ||
                 std::strcmp(name, "ubound") == 0)) {
-          // Check for an assumed-size array argument.
+          // Check for a whole assumed-size array argument.
           // These are disallowed for SHAPE, and require DIM= for
           // SIZE and UBOUND.
           // (A previous error message for UBOUND will take precedence
           // over this one, as this error is caught by the second entry
           // for UBOUND.)
-          if (const Symbol * argSym{GetLastSymbol(*arg)}) {
-            if (semantics::IsAssumedSizeArray(*argSym)) {
+          if (auto named{ExtractNamedEntity(*arg)}) {
+            if (semantics::IsAssumedSizeArray(named->GetLastSymbol())) {
               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,
Index: flang/include/flang/Evaluate/tools.h
===================================================================
--- flang/include/flang/Evaluate/tools.h
+++ flang/include/flang/Evaluate/tools.h
@@ -345,7 +345,7 @@
 
 template <typename A>
 std::optional<NamedEntity> ExtractNamedEntity(const A &x) {
-  if (auto dataRef{ExtractDataRef(x, true)}) {
+  if (auto dataRef{ExtractDataRef(x)}) {
     return common::visit(
         common::visitors{
             [](SymbolRef &&symbol) -> std::optional<NamedEntity> {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128391.439459.patch
Type: text/x-patch
Size: 2140 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220623/bbf356b5/attachment-0001.bin>


More information about the flang-commits mailing list