RFD: improved diagnostics when reading module files
Steve Kargl
sgk@troutmask.apl.washington.edu
Fri Apr 6 23:59:00 GMT 2018
On Fri, Apr 06, 2018 at 11:17:58PM +0200, Harald Anlauf wrote:
> On 04/06/18 21:58, Steve Kargl wrote:
> > I would remove the "While reading module files:" and simply
> > start the error message with "Mismatch". I haven't looked at
> > module.c, but if the module name or derived type is available
> > you might considering added that to the message. If you
> > try to reference a locus with "at %C", do you get a caret
> > pointing at a "USE XXXX" statement? This might also be helpful.
> >> + }
> >> + /* gcc_assert (comp_name == c->name); */
> >
> > Delete the above line.
>
> With
>
> Index: gcc/fortran/module.c
> ===================================================================
> --- gcc/fortran/module.c (revision 259189)
> +++ gcc/fortran/module.c (working copy)
> @@ -5161,7 +5161,12 @@
> if (p->u.pointer == NULL)
> associate_integer_pointer (p, c);
> mio_pool_string (&comp_name);
> - gcc_assert (comp_name == c->name);
> + if (comp_name != c->name)
> + {
> + gfc_error_now ("Mismatch in derived type components of "
> + "%qs from %qs at %C: %qs != %qs",
> + sym->name, sym->module, c->name,
> comp_name);
> + }
> skip_list (1); /* component end. */
> }
> mio_rparen (); /* component list closing. */
>
>
> I get some improved output. I'm not really overwhelmed, but it is
> definitely better from my point of view. OTOH, removing the %C
> makes the error message definitely less useful.
>
> I haven't been able to produce a simple but sufficiently contorted
> testcase. But for the case I was debugging, where there was some
> outdated module file holding the outdated layout of a derived type,
> I was able to zgrep back to the culprit.
>
> With the change above, I now get:
>
> ../../../../analysis/mo_ir_emis.f90:61:6:
>
> use mo_dec_matrix, only: t_vector ! decomposed vector
> 1
> Error: Mismatch in derived type components of 't_par_grib2' from
> 'mo_grib12_dwd' at (1): 'modnum' != 'shortname'
Yes, I think it is useful. An assert() gives an ICE, which is
not useful in this situation. A slight better error message
might be
Error: Mismatch in components of derived type 't_par_grib2' from
module 'mo_grib12_dwd' at (1) (expecting 'modnum', but got 'shortname')
You may want to let others way.
BTW, do you have commit privileges for the subversion repository?
--
Steve
More information about the Fortran
mailing list