-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[flang][hlfir] Fixed missing deallocation for components of function … #67768
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
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
! RUN: bbc -emit-hlfir -polymorphic-type %s -o - -I nowhere | FileCheck %s | ||
|
||
module types | ||
type t1 | ||
real :: x | ||
end type t1 | ||
type t2 | ||
real, allocatable :: x | ||
end type t2 | ||
type t3 | ||
real, pointer :: p | ||
end type t3 | ||
type t4 | ||
type(t1) :: c | ||
end type t4 | ||
type t5 | ||
type(t2) :: c | ||
end type t5 | ||
type t6 | ||
contains | ||
final :: finalize_t6 | ||
end type t6 | ||
type, extends(t1) :: t7 | ||
end type t7 | ||
type, extends(t2) :: t8 | ||
end type t8 | ||
type, extends(t6) :: t9 | ||
end type t9 | ||
contains | ||
subroutine finalize_t6(x) | ||
type(t6), intent(inout) :: x | ||
end subroutine finalize_t6 | ||
end module types | ||
|
||
subroutine test1 | ||
use types | ||
interface | ||
function ret_type_t1 | ||
use types | ||
type(t1) :: ret_type_t1 | ||
end function ret_type_t1 | ||
end interface | ||
type(t1) :: x | ||
x = ret_type_t1() | ||
end subroutine test1 | ||
! CHECK-LABEL: func.func @_QPtest1() { | ||
! CHECK-NOT: fir.call{{.*}}Destroy | ||
|
||
subroutine test1a | ||
use types | ||
interface | ||
function ret_type_t1a | ||
use types | ||
type(t1), allocatable :: ret_type_t1a | ||
end function ret_type_t1a | ||
end interface | ||
type(t1), allocatable :: x | ||
x = ret_type_t1a() | ||
end subroutine test1a | ||
! CHECK-LABEL: func.func @_QPtest1a() { | ||
! CHECK-NOT: fir.call{{.*}}Destroy | ||
! CHECK: fir.if %{{.*}} { | ||
! CHECK-NEXT: fir.freemem %{{.*}} : !fir.heap<!fir.type<_QMtypesTt1{x:f32}>> | ||
! CHECK-NOT: fir.call{{.*}}Destroy | ||
! CHECK: fir.if %{{.*}} { | ||
! CHECK: fir.call @_FortranAAllocatableDeallocate({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, i1, !fir.box<none>, !fir.ref<i8>, i32) -> i32 | ||
! CHECK-NOT: fir.call{{.*}}Destroy | ||
|
||
subroutine test1c | ||
use types | ||
interface | ||
function ret_class_t1 | ||
use types | ||
class(t1), allocatable :: ret_class_t1 | ||
end function ret_class_t1 | ||
end interface | ||
type(t1) :: x | ||
x = ret_class_t1() | ||
end subroutine test1c | ||
! CHECK-LABEL: func.func @_QPtest1c() { | ||
! CHECK: fir.call @_FortranADestroy | ||
! CHECK: fir.if %{{.*}} { | ||
! CHECK-NEXT: fir.freemem %{{.*}} : !fir.heap<!fir.type<_QMtypesTt1{x:f32}>> | ||
|
||
subroutine test2 | ||
use types | ||
interface | ||
function ret_type_t2 | ||
use types | ||
type(t2) :: ret_type_t2 | ||
end function ret_type_t2 | ||
end interface | ||
type(t2) :: x | ||
x = ret_type_t2() | ||
end subroutine test2 | ||
! CHECK-LABEL: func.func @_QPtest2() { | ||
! CHECK: fir.call @_FortranADestroy | ||
|
||
subroutine test3 | ||
use types | ||
interface | ||
function ret_type_t3 | ||
use types | ||
type(t3) :: ret_type_t3 | ||
end function ret_type_t3 | ||
end interface | ||
type(t3) :: x | ||
x = ret_type_t3() | ||
end subroutine test3 | ||
! CHECK-LABEL: func.func @_QPtest3() { | ||
! CHECK-NOT: fir.call{{.*}}Destroy | ||
|
||
subroutine test4 | ||
use types | ||
interface | ||
function ret_type_t4 | ||
use types | ||
type(t4) :: ret_type_t4 | ||
end function ret_type_t4 | ||
end interface | ||
type(t4) :: x | ||
x = ret_type_t4() | ||
end subroutine test4 | ||
! CHECK-LABEL: func.func @_QPtest4() { | ||
! CHECK-NOT: fir.call{{.*}}Destroy | ||
|
||
subroutine test5 | ||
use types | ||
interface | ||
function ret_type_t5 | ||
use types | ||
type(t5) :: ret_type_t5 | ||
end function ret_type_t5 | ||
end interface | ||
type(t5) :: x | ||
x = ret_type_t5() | ||
end subroutine test5 | ||
! CHECK-LABEL: func.func @_QPtest5() { | ||
! CHECK: fir.call @_FortranADestroy | ||
|
||
subroutine test6 | ||
use types | ||
interface | ||
function ret_type_t6 | ||
use types | ||
type(t6) :: ret_type_t6 | ||
end function ret_type_t6 | ||
end interface | ||
type(t6) :: x | ||
x = ret_type_t6() | ||
end subroutine test6 | ||
! CHECK-LABEL: func.func @_QPtest6() { | ||
! CHECK: fir.call @_FortranADestroy | ||
! CHECK: fir.call @_FortranADestroy | ||
|
||
subroutine test7 | ||
use types | ||
interface | ||
function ret_type_t7 | ||
use types | ||
type(t7) :: ret_type_t7 | ||
end function ret_type_t7 | ||
end interface | ||
type(t7) :: x | ||
x = ret_type_t7() | ||
end subroutine test7 | ||
! CHECK-LABEL: func.func @_QPtest7() { | ||
! CHECK-NOT: fir.call{{.*}}Destroy | ||
|
||
subroutine test8 | ||
use types | ||
interface | ||
function ret_type_t8 | ||
use types | ||
type(t8) :: ret_type_t8 | ||
end function ret_type_t8 | ||
end interface | ||
type(t8) :: x | ||
x = ret_type_t8() | ||
end subroutine test8 | ||
! CHECK-LABEL: func.func @_QPtest8() { | ||
! CHECK: fir.call @_FortranADestroy | ||
|
||
subroutine test9 | ||
use types | ||
interface | ||
function ret_type_t9 | ||
use types | ||
type(t9) :: ret_type_t9 | ||
end function ret_type_t9 | ||
end interface | ||
type(t9) :: x | ||
x = ret_type_t9() | ||
end subroutine test9 | ||
! CHECK-LABEL: func.func @_QPtest9() { | ||
! CHECK: fir.call @_FortranADestroy | ||
! CHECK: fir.call @_FortranADestroy |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.