From feb6eab0f59640cf19caa7bc09587b0c5a8a371f Mon Sep 17 00:00:00 2001 From: Paul Thomas <pault@gcc.gnu.org> Date: Tue, 15 Jan 2013 05:29:01 +0000 Subject: [PATCH] re PR fortran/54286 (Accepts invalid proc-pointer assignments involving proc-ptr function result) 2013-01-15 Paul Thomas <pault@gcc.gnu.org> PR fortran/54286 * expr.c (gfc_check_pointer_assign): Check for presence of 's2' before using it. 2013-01-15 Paul Thomas <pault@gcc.gnu.org> PR fortran/54286 * gfortran.dg/proc_ptr_result_8.f90 : Add module 'm' to check case where interface is null. From-SVN: r195185 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/expr.c | 2 +- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/proc_ptr_result_8.f90 | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b412d0a97b91..f297deb93add 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2013-01-15 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/54286 + * expr.c (gfc_check_pointer_assign): Check for presence of + 's2' before using it. + 2013-01-14 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/55806 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 3010dd9e4569..f358ac7665ea 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3537,7 +3537,7 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue) name = s2->name; } - if (s2->attr.proc_pointer && s2->ts.interface) + if (s2 && s2->attr.proc_pointer && s2->ts.interface) s2 = s2->ts.interface; if (s1 == s2 || !s1 || !s2) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e25cfc8bf0fc..b3dba4969d68 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2013-01-15 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/54286 + * gfortran.dg/proc_ptr_result_8.f90 : Add module 'm' to check + case where interface is null. + 2013-01-14 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/55806 diff --git a/gcc/testsuite/gfortran.dg/proc_ptr_result_8.f90 b/gcc/testsuite/gfortran.dg/proc_ptr_result_8.f90 index de6f39f910cc..17812bc4422f 100644 --- a/gcc/testsuite/gfortran.dg/proc_ptr_result_8.f90 +++ b/gcc/testsuite/gfortran.dg/proc_ptr_result_8.f90 @@ -2,7 +2,24 @@ ! Test fix for PR54286. ! ! Contributed by Janus Weil <janus@gcc.gnu.org> +! Module 'm' added later because original fix missed possibility of +! null interfaces - thanks to Dominique Dhumieres <dominiq@lps.ens.fr> ! +module m + type :: foobar + real, pointer :: array(:) + procedure (), pointer, nopass :: f + end type +contains + elemental subroutine fooAssgn (a1, a2) + type(foobar), intent(out) :: a1 + type(foobar), intent(in) :: a2 + allocate (a1%array(size(a2%array))) + a1%array = a2%array + a1%f => a2%f + end subroutine +end module m + implicit integer (a) type :: t procedure(a), pointer, nopass :: p -- GitLab