diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h --- a/flang/include/flang/Evaluate/tools.h +++ b/flang/include/flang/Evaluate/tools.h @@ -345,7 +345,7 @@ template std::optional ExtractNamedEntity(const A &x) { - if (auto dataRef{ExtractDataRef(x, true)}) { + if (auto dataRef{ExtractDataRef(x)}) { return common::visit( common::visitors{ [](SymbolRef &&symbol) -> std::optional { diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp --- a/flang/lib/Evaluate/intrinsics.cpp +++ b/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, diff --git a/flang/test/Semantics/misc-intrinsics.f90 b/flang/test/Semantics/misc-intrinsics.f90 --- a/flang/test/Semantics/misc-intrinsics.f90 +++ b/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