Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang] Check for polymorphism in DEALLOCATE statements in pure proce…
…dures Semantic checking for DEALLOCATE statements omitted checks for polymorphic objects and ultimate allocatable components in a pure procedure, which if not caught would allow execution of an impure FINAL subroutine defined on a type extension. Differential Revision: https://reviews.llvm.org/D140129
- Loading branch information
Showing
3 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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,21 @@ | ||
! RUN: %python %S/test_errors.py %s %flang_fc1 | ||
|
||
module m | ||
type t1 | ||
end type | ||
type t2 | ||
class(t2), allocatable :: pc | ||
end type | ||
contains | ||
pure subroutine subr(pp1, pp2, mp2) | ||
class(t1), intent(in out), pointer :: pp1 | ||
class(t2), intent(in out) :: pp2 | ||
type(t2), pointer :: mp2 | ||
!ERROR: 'pp1' may not be deallocated in a pure procedure because it is polymorphic | ||
deallocate(pp1) | ||
!ERROR: 'pc' may not be deallocated in a pure procedure because it is polymorphic | ||
deallocate(pp2%pc) | ||
!ERROR: 'mp2' may not be deallocated in a pure procedure because its type has a polymorphic allocatable ultimate component 'pc' | ||
deallocate(mp2) | ||
end subroutine | ||
end module |