Skip to content

Commit

Permalink
[flang] Fix IsDescriptor() to fix SMP compatibility checking (#70676)
Browse files Browse the repository at this point in the history
Fix IsDescriptor() so that it doesn't return a false negative result
that messes up compatibility checking between a separate module
procedure's interface and its redundant definition (without MODULE
PROCEDURE). Specifically, lower bounds just don't matter, and any upper
bound that's not explicit is dispositive.
  • Loading branch information
klausler committed Oct 31, 2023
1 parent 4c997e1 commit 2d4ada2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 1 addition & 7 deletions flang/lib/Evaluate/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,12 @@ static bool IsDescriptor(const ObjectEntityDetails &details) {
std::size_t j{0};
for (const ShapeSpec &shapeSpec : details.shape()) {
++j;
if (const auto &lb{shapeSpec.lbound().GetExplicit()};
!lb || !IsConstantExpr(*lb)) {
return true;
}
if (const auto &ub{shapeSpec.ubound().GetExplicit()}) {
if (!IsConstantExpr(*ub)) {
return true;
}
} else if (j == details.shape().size() && details.isDummy()) {
// assumed size array
} else {
return true;
return shapeSpec.ubound().isColon();
}
}
return false;
Expand Down
6 changes: 6 additions & 0 deletions flang/test/Semantics/separate-mp02.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ module subroutine s9(x, y, z, w)
character(len=*) :: z
character(len=*) :: w
end
module subroutine s10(x, y, z, w)
real x(0:), y(:), z(0:*), w(*)
end
end interface
end

Expand Down Expand Up @@ -78,6 +81,9 @@ module subroutine s9(x, y, z, w)
!ERROR: Dummy argument 'w' has type CHARACTER(KIND=1,LEN=4_8); the corresponding argument in the interface body has distinct type CHARACTER(KIND=1,LEN=*)
character(len=4) :: w
end
module subroutine s10(x, y, z, w)
real x(:), y(0:), z(*), w(0:*) ! all ok, lower bounds don't matter
end
end

module m2
Expand Down

0 comments on commit 2d4ada2

Please sign in to comment.