[flang-commits] [flang] 338e312 - [flang] Fix bogus warning about missing FINAL on assumed-rank (#66250)
via flang-commits
flang-commits at lists.llvm.org
Mon Sep 18 11:40:59 PDT 2023
Author: Peter Klausler
Date: 2023-09-18T11:40:55-07:00
New Revision: 338e312503d41c90b6d227227bc23cc6c7537936
URL: https://github.com/llvm/llvm-project/commit/338e312503d41c90b6d227227bc23cc6c7537936
DIFF: https://github.com/llvm/llvm-project/commit/338e312503d41c90b6d227227bc23cc6c7537936.diff
LOG: [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.
Added:
Modified:
flang/lib/Semantics/check-declarations.cpp
flang/test/Semantics/final02.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 52152fc19f55263..14f34666056e8e5 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -2058,7 +2058,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;
diff --git a/flang/test/Semantics/final02.f90 b/flang/test/Semantics/final02.f90
index b474f45ee5c327b..bea8f1b87ef5f6f 100644
--- a/flang/test/Semantics/final02.f90
+++ b/flang/test/Semantics/final02.f90
@@ -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
@@ -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
@@ -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
More information about the flang-commits
mailing list