Skip to content
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

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

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

klausler
Copy link
Contributor

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.

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.

Pull request: llvm#66250
@klausler klausler requested a review from a team as a code owner September 13, 2023 17:09
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Sep 13, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Sep 13, 2023

@llvm/pr-subscribers-flang-semantics

Changes 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. -- Full diff: https://github.com//pull/66250.diff

2 Files Affected:

  • (modified) flang/lib/Semantics/check-declarations.cpp (+1-1)
  • (modified) flang/test/Semantics/final02.f90 (+11-1)
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index e7e091ed024c48d..f76e69726cbf95b 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -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;
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

Copy link
Contributor

@vzakhari vzakhari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@klausler klausler merged commit 338e312 into llvm:main Sep 18, 2023
4 checks passed
@klausler klausler deleted the x8e branch September 18, 2023 18:40
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this pull request Sep 19, 2023
…6250)

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.
zahiraam pushed a commit to tahonermann/llvm-project that referenced this pull request Oct 24, 2023
…6250)

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.
zahiraam pushed a commit to tahonermann/llvm-project that referenced this pull request Oct 24, 2023
…6250)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants