https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86417
--- Comment #13 from janus at gcc dot gnu.org --- (In reply to Fritz Reese from comment #12) > If we set the component's locus when it is loaded from a module, the > following patch fixes the issue and retains sane location information for > the component and its initializer: > > diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c > index b120501beb7..27d68f6b1b5 100644 > --- a/gcc/fortran/module.c > +++ b/gcc/fortran/module.c > @@ -2848,6 +2848,8 @@ mio_component (gfc_component *c, int vtype) > if (c->attr.proc_pointer) > mio_typebound_proc (&c->tb); > > + c->loc = gfc_current_locus; > + > mio_rparen (); > } > > [..] > > I am currently running regression tests to verify these patches. If both > pass and I have not missed something obvious I would prefer adding location > info to the component when loading from a module (the first patch). I agree that this is probably the best way to fix it. If the patch regtests well, it's ok for trunk from my side. Thanks for having a look!