Commit 11e5274a by Janus Weil

gfortran.h (gfc_get_code): Modified prototype.

2013-08-09  Janus Weil  <janus@gcc.gnu.org>

	* gfortran.h (gfc_get_code): Modified prototype.
	* class.c (finalize_component, finalization_scalarizer,
	finalization_get_offset, finalizer_insert_packed_call,
	generate_finalization_wrapper, gfc_find_derived_vtab,
	gfc_find_intrinsic_vtab): Use 'gfc_get_code'.
	* io.c (match_io_iterator, match_io_element, terminate_io, get_io_list,
	gfc_match_inquire): Call 'gfc_get_code' with argument.
	* match.c (match_simple_forall, gfc_match_forall, gfc_match_goto,
	gfc_match_nullify, gfc_match_call, match_simple_where, gfc_match_where):
	Ditto.
	* parse.c (new_level): Ditto.
	(add_statement): Use XCNEW.
	* resolve.c (resolve_entries, resolve_allocate_expr,
	resolve_select_type, build_assignment, build_init_assign): Call
	'gfc_get_code' with argument.
	* st.c (gfc_get_code): Add argument 'op'.
	* trans-expr.c (gfc_trans_class_array_init_assign): Call 'gfc_get_code'
	with argument.
	* trans-stmt.c (gfc_trans_allocate): Ditto.

From-SVN: r201635
parent 2fa3d31b
2013-08-09 Janus Weil <janus@gcc.gnu.org>
* gfortran.h (gfc_get_code): Modified prototype.
* class.c (finalize_component, finalization_scalarizer,
finalization_get_offset, finalizer_insert_packed_call,
generate_finalization_wrapper, gfc_find_derived_vtab,
gfc_find_intrinsic_vtab): Use 'gfc_get_code'.
* io.c (match_io_iterator, match_io_element, terminate_io, get_io_list,
gfc_match_inquire): Call 'gfc_get_code' with argument.
* match.c (match_simple_forall, gfc_match_forall, gfc_match_goto,
gfc_match_nullify, gfc_match_call, match_simple_where, gfc_match_where):
Ditto.
* parse.c (new_level): Ditto.
(add_statement): Use XCNEW.
* resolve.c (resolve_entries, resolve_allocate_expr,
resolve_select_type, build_assignment, build_init_assign): Call
'gfc_get_code' with argument.
* st.c (gfc_get_code): Add argument 'op'.
* trans-expr.c (gfc_trans_class_array_init_assign): Call 'gfc_get_code'
with argument.
* trans-stmt.c (gfc_trans_allocate): Ditto.
2013-08-09 Janus Weil <janus@gcc.gnu.org>
PR fortran/58058
* trans-intrinsic.c (gfc_conv_intrinsic_transfer): Free the temporary
string, if necessary.
......
......@@ -2820,7 +2820,7 @@ bool gfc_check_vardef_context (gfc_expr*, bool, bool, bool, const char*);
extern gfc_code new_st;
void gfc_clear_new_st (void);
gfc_code *gfc_get_code (void);
gfc_code *gfc_get_code (gfc_exec_op);
gfc_code *gfc_append_code (gfc_code *, gfc_code *);
void gfc_free_statement (gfc_code *);
void gfc_free_statements (gfc_code *);
......
......@@ -3055,12 +3055,10 @@ match_io_iterator (io_kind k, gfc_code **result)
if (gfc_match_char (')') != MATCH_YES)
goto syntax;
new_code = gfc_get_code ();
new_code->op = EXEC_DO;
new_code = gfc_get_code (EXEC_DO);
new_code->ext.iterator = iter;
new_code->block = gfc_get_code ();
new_code->block->op = EXEC_DO;
new_code->block = gfc_get_code (EXEC_DO);
new_code->block->next = head;
*result = new_code;
......@@ -3117,8 +3115,7 @@ match_io_element (io_kind k, gfc_code **cpp)
return MATCH_ERROR;
}
cp = gfc_get_code ();
cp->op = EXEC_TRANSFER;
cp = gfc_get_code (EXEC_TRANSFER);
cp->expr1 = expr;
if (k != M_INQUIRE)
cp->ext.dt = current_dt;
......@@ -3180,8 +3177,7 @@ terminate_io (gfc_code *io_code)
if (io_code == NULL)
io_code = new_st.block;
c = gfc_get_code ();
c->op = EXEC_DT_END;
c = gfc_get_code (EXEC_DT_END);
/* Point to structure that is already there */
c->ext.dt = new_st.ext.dt;
......@@ -3751,8 +3747,7 @@ get_io_list:
new_st.op = (k == M_READ) ? EXEC_READ : EXEC_WRITE;
new_st.ext.dt = dt;
new_st.block = gfc_get_code ();
new_st.block->op = new_st.op;
new_st.block = gfc_get_code (new_st.op);
new_st.block->next = io_code;
terminate_io (io_code);
......@@ -3961,8 +3956,7 @@ gfc_match_inquire (void)
if (gfc_implicit_pure (NULL))
gfc_current_ns->proc_name->attr.implicit_pure = 0;
new_st.block = gfc_get_code ();
new_st.block->op = EXEC_IOLENGTH;
new_st.block = gfc_get_code (EXEC_IOLENGTH);
terminate_io (code);
new_st.block->next = code;
return MATCH_YES;
......
......@@ -1608,13 +1608,12 @@ got_match:
is in new_st. Rearrange things so that the IF statement appears
in new_st. */
p = gfc_get_code ();
p->next = gfc_get_code ();
p = gfc_get_code (EXEC_IF);
p->next = XCNEW (gfc_code);
*p->next = new_st;
p->next->loc = gfc_current_locus;
p->expr1 = expr;
p->op = EXEC_IF;
gfc_clear_new_st ();
......@@ -2224,7 +2223,7 @@ match_simple_forall (void)
goto syntax;
}
c = gfc_get_code ();
c = XCNEW (gfc_code);
*c = new_st;
c->loc = gfc_current_locus;
......@@ -2235,9 +2234,7 @@ match_simple_forall (void)
new_st.op = EXEC_FORALL;
new_st.expr1 = mask;
new_st.ext.forall_iterator = head;
new_st.block = gfc_get_code ();
new_st.block->op = EXEC_FORALL;
new_st.block = gfc_get_code (EXEC_FORALL);
new_st.block->next = c;
return MATCH_YES;
......@@ -2302,7 +2299,7 @@ gfc_match_forall (gfc_statement *st)
goto syntax;
}
c = gfc_get_code ();
c = XCNEW (gfc_code);
*c = new_st;
c->loc = gfc_current_locus;
......@@ -2310,8 +2307,7 @@ gfc_match_forall (gfc_statement *st)
new_st.op = EXEC_FORALL;
new_st.expr1 = mask;
new_st.ext.forall_iterator = head;
new_st.block = gfc_get_code ();
new_st.block->op = EXEC_FORALL;
new_st.block = gfc_get_code (EXEC_FORALL);
new_st.block->next = c;
*st = ST_FORALL;
......@@ -3283,15 +3279,14 @@ gfc_match_goto (void)
goto cleanup;
if (head == NULL)
head = tail = gfc_get_code ();
head = tail = gfc_get_code (EXEC_GOTO);
else
{
tail->block = gfc_get_code ();
tail->block = gfc_get_code (EXEC_GOTO);
tail = tail->block;
}
tail->label1 = label;
tail->op = EXEC_GOTO;
}
while (gfc_match_char (',') == MATCH_YES);
......@@ -3328,10 +3323,10 @@ gfc_match_goto (void)
goto cleanup;
if (head == NULL)
head = tail = gfc_get_code ();
head = tail = gfc_get_code (EXEC_SELECT);
else
{
tail->block = gfc_get_code ();
tail->block = gfc_get_code (EXEC_SELECT);
tail = tail->block;
}
......@@ -3339,11 +3334,9 @@ gfc_match_goto (void)
cp->low = cp->high = gfc_get_int_expr (gfc_default_integer_kind,
NULL, i++);
tail->op = EXEC_SELECT;
tail->ext.block.case_list = cp;
tail->next = gfc_get_code ();
tail->next->op = EXEC_GOTO;
tail->next = gfc_get_code (EXEC_GOTO);
tail->next->label1 = label;
}
while (gfc_match_char (',') == MATCH_YES);
......@@ -3800,14 +3793,16 @@ gfc_match_nullify (void)
/* Chain to list. */
if (tail == NULL)
tail = &new_st;
{
tail = &new_st;
tail->op = EXEC_POINTER_ASSIGN;
}
else
{
tail->next = gfc_get_code ();
tail->next = gfc_get_code (EXEC_POINTER_ASSIGN);
tail = tail->next;
}
tail->op = EXEC_POINTER_ASSIGN;
tail->expr1 = p;
tail->expr2 = e;
......@@ -4199,8 +4194,7 @@ gfc_match_call (void)
gfc_symbol *select_sym;
char name[GFC_MAX_SYMBOL_LEN + 1];
new_st.next = c = gfc_get_code ();
c->op = EXEC_SELECT;
new_st.next = c = gfc_get_code (EXEC_SELECT);
sprintf (name, "_result_%s", sym->name);
gfc_get_ha_sym_tree (name, &select_st); /* Can't fail. */
......@@ -4225,17 +4219,15 @@ gfc_match_call (void)
i++;
c->block = gfc_get_code ();
c->block = gfc_get_code (EXEC_SELECT);
c = c->block;
c->op = EXEC_SELECT;
new_case = gfc_get_case ();
new_case->high = gfc_get_int_expr (gfc_default_integer_kind, NULL, i);
new_case->low = new_case->high;
c->ext.block.case_list = new_case;
c->next = gfc_get_code ();
c->next->op = EXEC_GOTO;
c->next = gfc_get_code (EXEC_GOTO);
c->next->label1 = a->label;
}
}
......@@ -5639,12 +5631,10 @@ match_simple_where (void)
if (gfc_match_eos () != MATCH_YES)
goto syntax;
c = gfc_get_code ();
c->op = EXEC_WHERE;
c = gfc_get_code (EXEC_WHERE);
c->expr1 = expr;
c->next = gfc_get_code ();
c->next = XCNEW (gfc_code);
*c->next = new_st;
gfc_clear_new_st ();
......@@ -5699,12 +5689,10 @@ gfc_match_where (gfc_statement *st)
/* We've got a simple WHERE statement. */
*st = ST_WHERE;
c = gfc_get_code ();
c->op = EXEC_WHERE;
c = gfc_get_code (EXEC_WHERE);
c->expr1 = expr;
c->next = gfc_get_code ();
c->next = XCNEW (gfc_code);
*c->next = new_st;
gfc_clear_new_st ();
......
......@@ -1095,7 +1095,7 @@ new_level (gfc_code *q)
{
gfc_code *p;
p = q->block = gfc_get_code ();
p = q->block = gfc_get_code (EXEC_NOP);
gfc_state_stack->head = gfc_state_stack->tail = p;
......@@ -1111,7 +1111,7 @@ add_statement (void)
{
gfc_code *p;
p = gfc_get_code ();
p = XCNEW (gfc_code);
*p = new_st;
p->loc = gfc_current_locus;
......
......@@ -723,8 +723,7 @@ resolve_entries (gfc_namespace *ns)
el = ns->entries;
/* Add an entry statement for it. */
c = gfc_get_code ();
c->op = EXEC_ENTRY;
c = gfc_get_code (EXEC_ENTRY);
c->ext.entry = el;
c->next = ns->code;
ns->code = c;
......@@ -6880,9 +6879,8 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code)
if (ts.type == BT_DERIVED && (init_e = gfc_default_initializer (&ts)))
{
gfc_code *init_st = gfc_get_code ();
gfc_code *init_st = gfc_get_code (EXEC_INIT_ASSIGN);
init_st->loc = code->loc;
init_st->op = EXEC_INIT_ASSIGN;
init_st->expr1 = gfc_expr_to_initialize (e);
init_st->expr2 = init_e;
init_st->next = code->next;
......@@ -8020,8 +8018,7 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns)
code->ext.block.assoc = NULL;
/* Add EXEC_SELECT to switch on type. */
new_st = gfc_get_code ();
new_st->op = code->op;
new_st = gfc_get_code (code->op);
new_st->expr1 = code->expr1;
new_st->expr2 = code->expr2;
new_st->block = code->block;
......@@ -8087,8 +8084,7 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns)
if (c->ts.type != BT_CLASS && c->ts.type != BT_UNKNOWN)
gfc_add_data_component (st->n.sym->assoc->target);
new_st = gfc_get_code ();
new_st->op = EXEC_BLOCK;
new_st = gfc_get_code (EXEC_BLOCK);
new_st->ext.block.ns = gfc_build_block_ns (ns);
new_st->ext.block.ns->code = body->next;
body->next = new_st;
......@@ -8139,9 +8135,8 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns)
{
/* Add a default case to hold the CLASS IS cases. */
for (tail = code; tail->block; tail = tail->block) ;
tail->block = gfc_get_code ();
tail->block = gfc_get_code (EXEC_SELECT_TYPE);
tail = tail->block;
tail->op = EXEC_SELECT_TYPE;
tail->ext.block.case_list = gfc_get_case ();
tail->ext.block.case_list->ts.type = BT_UNKNOWN;
tail->next = NULL;
......@@ -8184,14 +8179,12 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns)
}
/* Generate IF chain. */
if_st = gfc_get_code ();
if_st->op = EXEC_IF;
if_st = gfc_get_code (EXEC_IF);
new_st = if_st;
for (body = class_is; body; body = body->block)
{
new_st->block = gfc_get_code ();
new_st->block = gfc_get_code (EXEC_IF);
new_st = new_st->block;
new_st->op = EXEC_IF;
/* Set up IF condition: Call _gfortran_is_extension_of. */
new_st->expr1 = gfc_get_expr ();
new_st->expr1->expr_type = EXPR_FUNCTION;
......@@ -8213,9 +8206,8 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns)
}
if (default_case->next)
{
new_st->block = gfc_get_code ();
new_st->block = gfc_get_code (EXEC_IF);
new_st = new_st->block;
new_st->op = EXEC_IF;
new_st->next = default_case->next;
}
......@@ -9241,8 +9233,7 @@ build_assignment (gfc_exec_op op, gfc_expr *expr1, gfc_expr *expr2,
{
gfc_code *this_code;
this_code = gfc_get_code ();
this_code->op = op;
this_code = gfc_get_code (op);
this_code->next = NULL;
this_code->expr1 = gfc_copy_expr (expr1);
this_code->expr2 = gfc_copy_expr (expr2);
......@@ -10281,13 +10272,12 @@ build_init_assign (gfc_symbol *sym, gfc_expr *init)
lval = gfc_lval_expr_from_sym (sym);
/* Add the code at scope entry. */
init_st = gfc_get_code ();
init_st = gfc_get_code (EXEC_INIT_ASSIGN);
init_st->next = ns->code;
ns->code = init_st;
/* Assign the default initializer to the l-value. */
init_st->loc = sym->declared_at;
init_st->op = EXEC_INIT_ASSIGN;
init_st->expr1 = lval;
init_st->expr2 = init;
}
......
......@@ -41,14 +41,16 @@ gfc_clear_new_st (void)
}
/* Get a gfc_code structure. */
/* Get a gfc_code structure, initialized with the current locus
and a statement code 'op'. */
gfc_code *
gfc_get_code (void)
gfc_get_code (gfc_exec_op op)
{
gfc_code *c;
c = XCNEW (gfc_code);
c->op = op;
c->loc = gfc_current_locus;
return c;
}
......
......@@ -895,14 +895,13 @@ gfc_trans_class_array_init_assign (gfc_expr *rhs, gfc_expr *lhs, gfc_expr *obj)
ppc = gfc_copy_expr (obj);
gfc_add_vptr_component (ppc);
gfc_add_component_ref (ppc, "_copy");
ppc_code = gfc_get_code ();
ppc_code = gfc_get_code (EXEC_CALL);
ppc_code->resolved_sym = ppc->symtree->n.sym;
/* Although '_copy' is set to be elemental in class.c, it is
not staying that way. Find out why, sometime.... */
ppc_code->resolved_sym->attr.elemental = 1;
ppc_code->ext.actual = actual;
ppc_code->expr1 = ppc;
ppc_code->op = EXEC_CALL;
/* Since '_copy' is elemental, the scalarizer will take care
of arrays in gfc_trans_call. */
res = gfc_trans_call (ppc_code, false, NULL, NULL, false);
......
......@@ -5232,14 +5232,13 @@ gfc_trans_allocate (gfc_code * code)
(gfc_find_intrinsic_vtab (&rhs->ts));
gfc_add_component_ref (ppc, "_copy");
ppc_code = gfc_get_code ();
ppc_code = gfc_get_code (EXEC_CALL);
ppc_code->resolved_sym = ppc->symtree->n.sym;
/* Although '_copy' is set to be elemental in class.c, it is
not staying that way. Find out why, sometime.... */
ppc_code->resolved_sym->attr.elemental = 1;
ppc_code->ext.actual = actual;
ppc_code->expr1 = ppc;
ppc_code->op = EXEC_CALL;
/* Since '_copy' is elemental, the scalarizer will take care
of arrays in gfc_trans_call. */
tmp = gfc_trans_call (ppc_code, true, NULL, NULL, false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment