RFD: improved diagnostics when reading module files
Harald Anlauf
anlauf@gmx.de
Fri Apr 6 21:18:00 GMT 2018
Steve,
I've tried to incorporate your suggestions.
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'
../../../../analysis/mo_ir_emis.f90:61:6: Error: Mismatch in derived
type components of 't_par_grib2' from 'mo_grib12_dwd' at (1):
'shortname' != 'longname'
f951: Fatal Error: Reading module 'mo_dec_matrix' at line 3072 column
53: Expected left parenthesis
compilation terminated.
That was useful enough for me, and I will continue using it.
If you think others may profit, please consider applying it.
Thanks,
Harald
More information about the Fortran
mailing list