Skip to content

[flang] Fix bogus warning about missing FINAL on assumed-rank #66250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ bool CheckHelper::CheckConflicting(const Symbol &symbol, Attr a1, Attr a2) {

void CheckHelper::WarnMissingFinal(const Symbol &symbol) {
const auto *object{symbol.detailsIf<ObjectEntityDetails>()};
if (!object ||
if (!object || object->IsAssumedRank() ||
(!IsAutomaticallyDestroyed(symbol) &&
symbol.owner().kind() != Scope::Kind::DerivedType)) {
return;
Expand Down
12 changes: 11 additions & 1 deletion flang/test/Semantics/final02.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ module m
!CHECK: 'matrix' of derived type 't1' does not have a FINAL subroutine for its rank (2)
type(t1) :: matrix(2, 2)
end type
type :: t6
integer :: n
contains
final :: t6f3
end type
contains
subroutine t1f0(x)
type(t1) :: x
Expand All @@ -38,9 +43,12 @@ impure elemental subroutine t2fe(x)
subroutine t3far(x)
type(t3) :: x(..)
end subroutine
subroutine t6f3(x)
type(t6) :: x(:,:,:)
end subroutine
end module

subroutine test ! *not* a main program, since they don't finalize locals
subroutine test(assumedRank) ! *not* a main program, since they don't finalize locals
use m
!CHECK-NOT: 'scalar1' of derived type 't1'
type(t1) :: scalar1
Expand All @@ -66,4 +74,6 @@ subroutine test ! *not* a main program, since they don't finalize locals
type(t4) :: vector4(2)
!CHECK: 'matrix4' of derived type 't4' extended from 't1' does not have a FINAL subroutine for its rank (2)
type(t4) :: matrix4(2,2)
!CHECK-NOT: 'assumedRank' of derived type 't6'
type(t6) :: assumedRank(..)
end