static void formalize_init_expr (gfc_expr * expr) { expr_t type; gfc_constructor *c; if (expr == NULL) return; type = expr->expr_type; switch (type) { case EXPR_ARRAY: c = expr->value.constructor; while (c) { formalize_init_expr (c->expr); c = c->next; } break; case EXPR_STRUCTURE: formalize_structure_cons (expr); break; default: break; } }
static void formalize_init_expr (gfc_expr *expr) { expr_t type; gfc_constructor *c; if (expr == NULL) return; type = expr->expr_type; switch (type) { case EXPR_ARRAY: for (c = gfc_constructor_first (expr->value.constructor); c; c = gfc_constructor_next (c)) formalize_init_expr (c->expr); break; case EXPR_STRUCTURE: formalize_structure_cons (expr); break; default: break; } }
static void formalize_structure_cons (gfc_expr * expr) { gfc_constructor *head; gfc_constructor *tail; gfc_constructor *cur; gfc_constructor *last; gfc_constructor *c; gfc_component *order; c = expr->value.constructor; /* Constructor is already formalized. */ if (c->n.component == NULL) return; head = tail = NULL; for (order = expr->ts.derived->components; order; order = order->next) { /* Find the next component. */ last = NULL; cur = c; while (cur != NULL && cur->n.component != order) { last = cur; cur = cur->next; } if (cur == NULL) { /* Create a new one. */ cur = gfc_get_constructor (); } else { /* Remove it from the chain. */ if (last == NULL) c = cur->next; else last->next = cur->next; cur->next = NULL; formalize_init_expr (cur->expr); } /* Add it to the new constructor. */ if (head == NULL) head = tail = cur; else { tail->next = cur; tail = tail->next; } } gcc_assert (c == NULL); expr->value.constructor = head; }
void gfc_formalize_init_value (gfc_symbol *sym) { formalize_init_expr (sym->value); }