forked from wangliu-iscas/gcc-patch
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fortran: CLASS pointer function result in variable definition context…
… [PR109846] gcc/fortran/ChangeLog: PR fortran/109846 * expr.cc (gfc_check_vardef_context): Check appropriate pointer attribute for CLASS vs. non-CLASS function result in variable definition context. gcc/testsuite/ChangeLog: PR fortran/109846 * gfortran.dg/ptr-func-5.f90: New test.
- Loading branch information
1 parent
c2d62cd
commit 476fd25
Showing
2 changed files
with
40 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
! { dg-do compile } | ||
! PR fortran/109846 | ||
! CLASS pointer function result in variable definition context | ||
|
||
module foo | ||
implicit none | ||
type :: parameter_list | ||
contains | ||
procedure :: sublist, sublist_nores | ||
end type | ||
contains | ||
function sublist (this) result (slist) | ||
class(parameter_list), intent(inout) :: this | ||
class(parameter_list), pointer :: slist | ||
allocate (slist) | ||
end function | ||
function sublist_nores (this) | ||
class(parameter_list), intent(inout) :: this | ||
class(parameter_list), pointer :: sublist_nores | ||
allocate (sublist_nores) | ||
end function | ||
end module | ||
|
||
program example | ||
use foo | ||
implicit none | ||
type(parameter_list) :: plist | ||
call sub1 (plist%sublist()) | ||
call sub1 (plist%sublist_nores()) | ||
call sub2 (plist%sublist()) | ||
call sub2 (plist%sublist_nores()) | ||
contains | ||
subroutine sub1 (plist) | ||
type(parameter_list), intent(inout) :: plist | ||
end subroutine | ||
subroutine sub2 (plist) | ||
type(parameter_list) :: plist | ||
end subroutine | ||
end program |