Commit b5c26787 by Janus Weil

re PR fortran/84504 ([F08] procedure pointer variables cannot be initialized…

re PR fortran/84504 ([F08] procedure pointer variables cannot be initialized with functions returning pointers)

fix PR 84504

2019-03-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/84504
	* expr.c (gfc_check_assign_symbol): Deal with procedure pointers to
	pointer-valued functions.

2019-03-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/84504
	* gfortran.dg/pointer_init_10.f90: New test case.

From-SVN: r269529
parent 660de2ba
2019-03-09 Janus Weil <janus@gcc.gnu.org>
PR fortran/84504
* expr.c (gfc_check_assign_symbol): Deal with procedure pointers to
pointer-valued functions.
2019-03-09 Thomas König <tkoenig@gcc.gnu.org> 2019-03-09 Thomas König <tkoenig@gcc.gnu.org>
PR fortran/71203 PR fortran/71203
......
...@@ -4321,7 +4321,7 @@ gfc_check_assign_symbol (gfc_symbol *sym, gfc_component *comp, gfc_expr *rvalue) ...@@ -4321,7 +4321,7 @@ gfc_check_assign_symbol (gfc_symbol *sym, gfc_component *comp, gfc_expr *rvalue)
if (!r) if (!r)
return r; return r;
if (pointer && rvalue->expr_type != EXPR_NULL) if (pointer && rvalue->expr_type != EXPR_NULL && !proc_pointer)
{ {
/* F08:C461. Additional checks for pointer initialization. */ /* F08:C461. Additional checks for pointer initialization. */
symbol_attribute attr; symbol_attribute attr;
......
2019-03-09 Janus Weil <janus@gcc.gnu.org>
PR fortran/84504
* gfortran.dg/pointer_init_10.f90: New test case.
2019-03-09 John David Anglin <dave.anglin@bell.net> 2019-03-09 John David Anglin <dave.anglin@bell.net>
* gfortran.dg/ieee/ieee_9.f90: Fix typo. * gfortran.dg/ieee/ieee_9.f90: Fix typo.
......
! { dg-do run }
!
! PR 84504: [F08] procedure pointer variables cannot be initialized with functions returning pointers
!
! Contributed by Sriram Swaminarayan <sriram@pobox.com>
module test_mod
implicit none
private
integer, target :: i = 333
procedure(the_proc), pointer, public :: ptr => the_proc
contains
function the_proc()
integer, pointer :: the_proc
the_proc => i
end function
end module
program test_prog
use test_mod
integer, pointer :: ip
ip => ptr()
if (ip /= 333) stop 1
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment