re PR fortran/56477 (ICE on invalid with pointer assignment to function result)

fortran/
	PR fortran/56477
	* expr.c (gfc_check_pointer_assign): Avoid NULL pointer dereference.

testsuite/
	PR fortran/56477
	* gfortran.dg/pointer_check_13.f90: New test.

From-SVN: r196417
This commit is contained in:
Mikael Morin 2013-03-03 19:58:49 +00:00
parent d6a5de1615
commit 1216b4d21d
4 changed files with 30 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2013-03-03 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/56477
* expr.c (gfc_check_pointer_assign): Avoid NULL pointer dereference.
2013-03-03 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/54730

View File

@ -3732,7 +3732,7 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue)
&& rvalue->symtree->n.sym->ns->proc_name->attr.flavor != FL_PROCEDURE
&& rvalue->symtree->n.sym->ns->proc_name->attr.flavor != FL_PROGRAM)
for (ns = rvalue->symtree->n.sym->ns;
ns->proc_name && ns->proc_name->attr.flavor != FL_PROCEDURE;
ns && ns->proc_name && ns->proc_name->attr.flavor != FL_PROCEDURE;
ns = ns->parent)
if (ns->parent == lvalue->symtree->n.sym->ns)
warn = true;

View File

@ -1,3 +1,8 @@
2013-03-03 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/56477
* gfortran.dg/pointer_check_13.f90: New test.
2013-03-03 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/54730

View File

@ -0,0 +1,19 @@
! { dg-do compile }
! { dg-options "-Wall -Wno-uninitialized" }
!
! PR fortran/56477
! The pointer target live range checking code used to trigger a NULL pointer
! dereference with the following case.
!
! Contributed by Andrew Benson <abensonca@gmail.com>
!
module s
contains
function so()
implicit none
integer, target :: so
integer, pointer :: sp
sp => so
return
end function So
end module s