+2007-10-28 Tobias Schlüter <tobi@gcc.gnu.org>
+
+ PR fortran/32147
+ * module.c (write_symbol): Fix whitespace.
+ (write_symbol0): Walk symtree from left-to-right instead
+ breadth-first.
+ (write_symbol1): Similarly change walk of pointer info tree.
+ (write_module): Insert linebreak.
+ * symbol.c (gfc_traverse_symtree): Change to left-to-right order.
+ (traverse_ns): Likewise.
+
2007-10-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/31306
static void
write_symbol (int n, gfc_symbol *sym)
{
- const char *label;
+ const char *label;
if (sym->attr.flavor == FL_UNKNOWN || sym->attr.flavor == FL_LABEL)
gfc_internal_error ("write_symbol(): bad module symbol '%s'", sym->name);
{
gfc_symbol *sym;
pointer_info *p;
+ bool dont_write = false;
if (st == NULL)
return;
write_symbol0 (st->left);
- write_symbol0 (st->right);
sym = st->n.sym;
if (sym->module == NULL)
if (sym->attr.flavor == FL_PROCEDURE && sym->attr.generic
&& !sym->attr.subroutine && !sym->attr.function)
- return;
+ dont_write = true;
if (!gfc_check_access (sym->attr.access, sym->ns->default_access))
- return;
+ dont_write = true;
- p = get_pointer (sym);
- if (p->type == P_UNKNOWN)
- p->type = P_SYMBOL;
+ if (!dont_write)
+ {
+ p = get_pointer (sym);
+ if (p->type == P_UNKNOWN)
+ p->type = P_SYMBOL;
- if (p->u.wsym.state == WRITTEN)
- return;
+ if (p->u.wsym.state != WRITTEN)
+ {
+ write_symbol (p->integer, sym);
+ p->u.wsym.state = WRITTEN;
+ }
+ }
- write_symbol (p->integer, sym);
- p->u.wsym.state = WRITTEN;
+ write_symbol0 (st->right);
}
static int
write_symbol1 (pointer_info *p)
{
+ int result;
- if (p == NULL)
+ if (!p)
return 0;
- if (write_symbol1 (p->left))
- return 1;
- if (write_symbol1 (p->right))
- return 1;
+ result = write_symbol1 (p->left);
- if (p->type != P_SYMBOL || p->u.wsym.state != NEEDS_WRITE)
- return 0;
-
- p->u.wsym.state = WRITTEN;
- write_symbol (p->integer, p->u.wsym.sym);
+ if (!(p->type != P_SYMBOL || p->u.wsym.state != NEEDS_WRITE))
+ {
+ p->u.wsym.state = WRITTEN;
+ write_symbol (p->integer, p->u.wsym.sym);
+ result = 1;
+ }
- return 1;
+ result |= write_symbol1 (p->right);
+ return result;
}
mio_lparen ();
write_symbol0 (gfc_current_ns->sym_root);
- while (write_symbol1 (pi_root));
+ while (write_symbol1 (pi_root))
+ /* Nothing. */;
mio_rparen ();
void
gfc_traverse_symtree (gfc_symtree *st, void (*func) (gfc_symtree *))
{
- if (st != NULL)
- {
- (*func) (st);
+ if (!st)
+ return;
- gfc_traverse_symtree (st->left, func);
- gfc_traverse_symtree (st->right, func);
- }
+ gfc_traverse_symtree (st->left, func);
+ (*func) (st);
+ gfc_traverse_symtree (st->right, func);
}
if (st == NULL)
return;
+ traverse_ns (st->left, func);
+
if (st->n.sym->mark == 0)
(*func) (st->n.sym);
st->n.sym->mark = 1;
- traverse_ns (st->left, func);
traverse_ns (st->right, func);
}