Patch below prevents printing of duplicate statements in module files.
Without it module files grow exponentially in size with nested use of
modules that contain equivalence statements. Tested on x86-64-linux.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60780
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40958
2015-05-14
PR fortran 60780
* module.c (load_equiv) : add check for duplicate modules
Index: module.c
===================================================================
--- module.c (revision 223202)
+++ module.c (working copy)
@@ -4479,8 +4479,8 @@
static void
load_equiv (void)
{
- gfc_equiv *head, *tail, *end, *eq;
- bool unused;
+ gfc_equiv *head, *tail, *end, *eq, *equiv;
+ bool unused, duplicate;
mio_lparen ();
in_load_equiv = true;
@@ -4523,8 +4523,20 @@
}
}
- if (unused)
+ /* Check for duplicate equivalences being loaded from different
modules */
+ duplicate = false;
+ for (equiv = gfc_current_ns->equiv; equiv; equiv = equiv->next)
{
+ if (equiv->module && head->module
+ && strcmp (equiv->module, head->module) == 0)
+ {
+ duplicate = true;
+ break;
+ }
+ }
+
+ if (unused || duplicate)
+ {
for (eq = head; eq; eq = head)
{
head = eq->eq;