https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86417

--- Comment #11 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to janus from comment #10)
> (In reply to janus from comment #9)
> > The following patch seems to be sufficient to fix the regression:
> 
> 
> ... however, it lacks a safety check for the existence of the ctor
> expression. This variant regtests cleanly:
> 
> 
> Index: gcc/fortran/expr.c
> ===================================================================
> --- gcc/fortran/expr.c        (revision 262509)
> +++ gcc/fortran/expr.c        (working copy)
> @@ -4650,6 +4650,10 @@ gfc_generate_initializer (gfc_typespec *ts, bool g
>           }
>       }
>  
> +      /* Make sure that locus is set.  */
> +      if (ctor->expr && (!ctor->expr->where.nextc || !ctor->expr->where.lb))
> +     ctor->expr->where = init->where;
> +
>        gfc_constructor_append (&init->value.constructor, ctor);
>      }

If possible, I would prefer to set the locus where it is generated,
not conditionally later.

Unfortunately, I cannot currently look into this due to PR 86450 :-(

If I had a bootstrapping gcc, I would probably look at

      /* Fetch or generate an initializer for the component.  */
      tmp = component_initializer (comp, generate);

and see if the locus is set correctly at that point, then
(possibly) go back to component_initializer to see where this is
missing.

Reply via email to