Dear All,

Some problems have come up that are not dissimilar to the original
bug, involving infinite recursion with procedure components, with the
same type as the containing type. The fix is verging on the trivial.
However, given that I found two further bugs in fixing the one
reported, I worry that there are more lurking nearby.

Bootstraps and regtests on x86_64 - OK for trunk and, in a couple of
weeks 5 and 4.9 branches?

Cheers

Paul

2015-12-17  Paul Thomas  <pa...@gcc.gnu.org>

PR fortran/68196
*expr.c (gfc_has_default_initializer): Prevent infinite recursion
through this function for procedure pointer components.
* trans-array.c (structure_alloc_comps): Ditto times two.


2015-12-17  Paul Thomas  <pa...@gcc.gnu.org>

PR fortran/68196
* gfortran.dg/proc_ptr_48.f90: New test.
Index: gcc/fortran/expr.c
===================================================================
*** gcc/fortran/expr.c  (revision 231253)
--- gcc/fortran/expr.c  (working copy)
*************** gfc_has_default_initializer (gfc_symbol
*** 3930,3936 ****
    for (c = der->components; c; c = c->next)
      if (c->ts.type == BT_DERIVED)
        {
!         if (!c->attr.pointer
             && gfc_has_default_initializer (c->ts.u.derived))
          return true;
        if (c->attr.pointer && c->initializer)
--- 3930,3936 ----
    for (c = der->components; c; c = c->next)
      if (c->ts.type == BT_DERIVED)
        {
!         if (!c->attr.pointer && !c->attr.proc_pointer
             && gfc_has_default_initializer (c->ts.u.derived))
          return true;
        if (c->attr.pointer && c->initializer)
Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c   (revision 231253)
--- gcc/fortran/trans-array.c   (working copy)
*************** structure_alloc_comps (gfc_symbol * der_
*** 8074,8080 ****
            }

          if (cmp_has_alloc_comps
!               && !c->attr.pointer
                && !called_dealloc_with_status)
            {
              /* Do not deallocate the components of ultimate pointer
--- 8075,8081 ----
            }

          if (cmp_has_alloc_comps
!               && !c->attr.pointer && !c->attr.proc_pointer
                && !called_dealloc_with_status)
            {
              /* Do not deallocate the components of ultimate pointer
*************** structure_alloc_comps (gfc_symbol * der_
*** 8264,8270 ****
             components that are really allocated, the deep copy code has to
             be generated first and then added to the if-block in
             gfc_duplicate_allocatable ().  */
!         if (cmp_has_alloc_comps)
            {
              rank = c->as ? c->as->rank : 0;
              tmp = fold_convert (TREE_TYPE (dcmp), comp);
--- 8265,8272 ----
             components that are really allocated, the deep copy code has to
             be generated first and then added to the if-block in
             gfc_duplicate_allocatable ().  */
!         if (cmp_has_alloc_comps
!             && !c->attr.proc_pointer)
            {
              rank = c->as ? c->as->rank : 0;
              tmp = fold_convert (TREE_TYPE (dcmp), comp);

Reply via email to