The attached patch is trivial, allowing procedure pointer components to be initaialized to NULL (), and fixes bug13-proc-ptr-comp-init-ice.f90.
Passes regtesting on FC44/x86_64. OK for mainline. Cheers Paul
From 5e5a7f7f64f113a59b49909f0b17e69098371975 Mon Sep 17 00:00:00 2001 From: Paul Thomas <[email protected]> Date: Wed, 7 Oct 2026 10:46:15 +0100 Subject: [PATCH] Fortran: [meta-bug] [PDT] Parameterized derived type errors [PR82173] 2026-10-07 Paul Thomas <[email protected]> gcc/fortran PR fortran/82173 * expr.cc (gfc_check_pointer_assign): If rvalue is expr_NULL, return true. gcc/testsuite/ PR fortran/82173 * gfortran.dg/pdt_bug13.f90: New test. --- gcc/fortran/expr.cc | 2 ++ gcc/testsuite/gfortran.dg/pdt_bug13.f90 | 30 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pdt_bug13.f90 diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index bdd7a200822..6cb38578b31 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -4550,6 +4550,8 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue, name = s2->name; } + else if (rvalue->expr_type == EXPR_NULL) + return true; else { s2 = rvalue->symtree->n.sym; diff --git a/gcc/testsuite/gfortran.dg/pdt_bug13.f90 b/gcc/testsuite/gfortran.dg/pdt_bug13.f90 new file mode 100644 index 00000000000..be27159dfe7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pdt_bug13.f90 @@ -0,0 +1,30 @@ +! { dg-do run } +! See attachment to PR82173 comment 10 - bug13-proc-ptr-comp-init-ice.f90 +module ml + type :: t(n) + integer, len :: n = 1 + real :: v(n) + procedure(reducer), pointer, nopass :: op => null () ! ICE + end type + abstract interface + real function reducer (x) + real, intent(in) :: x(:) + end function + end interface +end module +program l1 + use ml + type(t(3)) :: a + a%v = 1.0 + if (associated (a%op)) stop 1 + a%op => tgt + if (.not.associated (a%op)) stop 2 ! Check normal functioning not affected + if (a%op ([1.,2.,3.,4.]) /= 10) stop 3 + a%op => NULL () + if (associated (a%op)) stop 4 +contains + real function tgt (x) + real, intent(in) :: x(:) + tgt = sum (x) + end function +end program -- 2.55.0
