Skip to content

Commit 338e312

Browse files
authored
[flang] Fix bogus warning about missing FINAL on assumed-rank (#66250)
The warning message about a derived type not having a FINAL subroutine for a particular object's rank should not issue for an assumed-rank dummy argument.
1 parent c2e248c commit 338e312

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ bool CheckHelper::CheckConflicting(const Symbol &symbol, Attr a1, Attr a2) {
20582058

20592059
void CheckHelper::WarnMissingFinal(const Symbol &symbol) {
20602060
const auto *object{symbol.detailsIf<ObjectEntityDetails>()};
2061-
if (!object ||
2061+
if (!object || object->IsAssumedRank() ||
20622062
(!IsAutomaticallyDestroyed(symbol) &&
20632063
symbol.owner().kind() != Scope::Kind::DerivedType)) {
20642064
return;

flang/test/Semantics/final02.f90

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ module m
2525
!CHECK: 'matrix' of derived type 't1' does not have a FINAL subroutine for its rank (2)
2626
type(t1) :: matrix(2, 2)
2727
end type
28+
type :: t6
29+
integer :: n
30+
contains
31+
final :: t6f3
32+
end type
2833
contains
2934
subroutine t1f0(x)
3035
type(t1) :: x
@@ -38,9 +43,12 @@ impure elemental subroutine t2fe(x)
3843
subroutine t3far(x)
3944
type(t3) :: x(..)
4045
end subroutine
46+
subroutine t6f3(x)
47+
type(t6) :: x(:,:,:)
48+
end subroutine
4149
end module
4250

43-
subroutine test ! *not* a main program, since they don't finalize locals
51+
subroutine test(assumedRank) ! *not* a main program, since they don't finalize locals
4452
use m
4553
!CHECK-NOT: 'scalar1' of derived type 't1'
4654
type(t1) :: scalar1
@@ -66,4 +74,6 @@ subroutine test ! *not* a main program, since they don't finalize locals
6674
type(t4) :: vector4(2)
6775
!CHECK: 'matrix4' of derived type 't4' extended from 't1' does not have a FINAL subroutine for its rank (2)
6876
type(t4) :: matrix4(2,2)
77+
!CHECK-NOT: 'assumedRank' of derived type 't6'
78+
type(t6) :: assumedRank(..)
6979
end

0 commit comments

Comments
 (0)