Skip to content

Commit

Permalink
[flang] Fix check for assumed-size arguments to SHAPE() & al.
Browse files Browse the repository at this point in the history
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.

Differential Revision: https://reviews.llvm.org/D125342
  • Loading branch information
klausler committed May 11, 2022
1 parent 9873623 commit d80d812
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flang/lib/Evaluate/intrinsics.cpp
Expand Up @@ -1563,8 +1563,8 @@ std::optional<SpecificCall> IntrinsicInterface::Match(
// (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,
Expand Down

0 comments on commit d80d812

Please sign in to comment.