Commit 8748ad99 by Nathan Froyd Committed by Nathan Froyd

trans-array.c (gfc_trans_array_constructor_value): Use build_constructor instead…

trans-array.c (gfc_trans_array_constructor_value): Use build_constructor instead of build_constructor_from_list.

	* trans-array.c (gfc_trans_array_constructor_value): Use
	build_constructor instead of build_constructor_from_list.
	(gfc_build_constant_array_constructor): Likewise.
	* trans-decl.c (create_main_function): Likewise.
	* trans-stmt.c (gfc_trans_character_select): Likewise.

From-SVN: r159490
parent 2882bfcc
2010-05-17 Nathan Froyd <froydnj@cs.rice.edu>
* trans-array.c (gfc_trans_array_constructor_value): Use
build_constructor instead of build_constructor_from_list.
(gfc_build_constant_array_constructor): Likewise.
* trans-decl.c (create_main_function): Likewise.
* trans-stmt.c (gfc_trans_character_select): Likewise.
2010-05-17 Janus Weil <janus@gcc.gnu.org> 2010-05-17 Janus Weil <janus@gcc.gnu.org>
PR fortran/44044 PR fortran/44044
......
...@@ -1308,14 +1308,13 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, ...@@ -1308,14 +1308,13 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type,
else else
{ {
/* Collect multiple scalar constants into a constructor. */ /* Collect multiple scalar constants into a constructor. */
tree list; VEC(constructor_elt,gc) *v = NULL;
tree init; tree init;
tree bound; tree bound;
tree tmptype; tree tmptype;
HOST_WIDE_INT idx = 0; HOST_WIDE_INT idx = 0;
p = c; p = c;
list = NULL_TREE;
/* Count the number of consecutive scalar constants. */ /* Count the number of consecutive scalar constants. */
while (p && !(p->iterator while (p && !(p->iterator
|| p->expr->expr_type != EXPR_CONSTANT)) || p->expr->expr_type != EXPR_CONSTANT))
...@@ -1332,8 +1331,10 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, ...@@ -1332,8 +1331,10 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type,
(gfc_get_pchar_type (p->expr->ts.kind), (gfc_get_pchar_type (p->expr->ts.kind),
se.expr); se.expr);
list = tree_cons (build_int_cst (gfc_array_index_type, CONSTRUCTOR_APPEND_ELT (v,
idx++), se.expr, list); build_int_cst (gfc_array_index_type,
idx++),
se.expr);
c = p; c = p;
p = gfc_constructor_next (p); p = gfc_constructor_next (p);
} }
...@@ -1344,7 +1345,7 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, ...@@ -1344,7 +1345,7 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type,
gfc_index_zero_node, bound); gfc_index_zero_node, bound);
tmptype = build_array_type (type, tmptype); tmptype = build_array_type (type, tmptype);
init = build_constructor_from_list (tmptype, nreverse (list)); init = build_constructor (tmptype, v);
TREE_CONSTANT (init) = 1; TREE_CONSTANT (init) = 1;
TREE_STATIC (init) = 1; TREE_STATIC (init) = 1;
/* Create a static variable to hold the data. */ /* Create a static variable to hold the data. */
...@@ -1671,17 +1672,17 @@ gfc_constant_array_constructor_p (gfc_constructor_base base) ...@@ -1671,17 +1672,17 @@ gfc_constant_array_constructor_p (gfc_constructor_base base)
tree tree
gfc_build_constant_array_constructor (gfc_expr * expr, tree type) gfc_build_constant_array_constructor (gfc_expr * expr, tree type)
{ {
tree tmptype, list, init, tmp; tree tmptype, init, tmp;
HOST_WIDE_INT nelem; HOST_WIDE_INT nelem;
gfc_constructor *c; gfc_constructor *c;
gfc_array_spec as; gfc_array_spec as;
gfc_se se; gfc_se se;
int i; int i;
VEC(constructor_elt,gc) *v = NULL;
/* First traverse the constructor list, converting the constants /* First traverse the constructor list, converting the constants
to tree to build an initializer. */ to tree to build an initializer. */
nelem = 0; nelem = 0;
list = NULL_TREE;
c = gfc_constructor_first (expr->value.constructor); c = gfc_constructor_first (expr->value.constructor);
while (c) while (c)
{ {
...@@ -1692,8 +1693,8 @@ gfc_build_constant_array_constructor (gfc_expr * expr, tree type) ...@@ -1692,8 +1693,8 @@ gfc_build_constant_array_constructor (gfc_expr * expr, tree type)
else if (POINTER_TYPE_P (type)) else if (POINTER_TYPE_P (type))
se.expr = gfc_build_addr_expr (gfc_get_pchar_type (c->expr->ts.kind), se.expr = gfc_build_addr_expr (gfc_get_pchar_type (c->expr->ts.kind),
se.expr); se.expr);
list = tree_cons (build_int_cst (gfc_array_index_type, nelem), CONSTRUCTOR_APPEND_ELT (v, build_int_cst (gfc_array_index_type, nelem),
se.expr, list); se.expr);
c = gfc_constructor_next (c); c = gfc_constructor_next (c);
nelem++; nelem++;
} }
...@@ -1723,7 +1724,7 @@ gfc_build_constant_array_constructor (gfc_expr * expr, tree type) ...@@ -1723,7 +1724,7 @@ gfc_build_constant_array_constructor (gfc_expr * expr, tree type)
tmptype = gfc_get_nodesc_array_type (type, &as, PACKED_STATIC, true); tmptype = gfc_get_nodesc_array_type (type, &as, PACKED_STATIC, true);
init = build_constructor_from_list (tmptype, nreverse (list)); init = build_constructor (tmptype, v);
TREE_CONSTANT (init) = 1; TREE_CONSTANT (init) = 1;
TREE_STATIC (init) = 1; TREE_STATIC (init) = 1;
......
...@@ -4196,6 +4196,7 @@ create_main_function (tree fndecl) ...@@ -4196,6 +4196,7 @@ create_main_function (tree fndecl)
language standard parameters. */ language standard parameters. */
{ {
tree array_type, array, var; tree array_type, array, var;
VEC(constructor_elt,gc) *v = NULL;
/* Passing a new option to the library requires four modifications: /* Passing a new option to the library requires four modifications:
+ add it to the tree_cons list below + add it to the tree_cons list below
...@@ -4204,28 +4205,34 @@ create_main_function (tree fndecl) ...@@ -4204,28 +4205,34 @@ create_main_function (tree fndecl)
gfor_fndecl_set_options gfor_fndecl_set_options
+ modify the library (runtime/compile_options.c)! */ + modify the library (runtime/compile_options.c)! */
array = tree_cons (NULL_TREE, build_int_cst (integer_type_node, CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
gfc_option.warn_std), NULL_TREE); build_int_cst (integer_type_node,
array = tree_cons (NULL_TREE, build_int_cst (integer_type_node, gfc_option.warn_std));
gfc_option.allow_std), array); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
array = tree_cons (NULL_TREE, build_int_cst (integer_type_node, pedantic), build_int_cst (integer_type_node,
array); gfc_option.allow_std));
array = tree_cons (NULL_TREE, build_int_cst (integer_type_node, CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
gfc_option.flag_dump_core), array); build_int_cst (integer_type_node, pedantic));
array = tree_cons (NULL_TREE, build_int_cst (integer_type_node, CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
gfc_option.flag_backtrace), array); build_int_cst (integer_type_node,
array = tree_cons (NULL_TREE, build_int_cst (integer_type_node, gfc_option.flag_dump_core));
gfc_option.flag_sign_zero), array); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
build_int_cst (integer_type_node,
array = tree_cons (NULL_TREE, build_int_cst (integer_type_node, gfc_option.flag_backtrace));
(gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)), array); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
build_int_cst (integer_type_node,
array = tree_cons (NULL_TREE, build_int_cst (integer_type_node, gfc_option.flag_sign_zero));
gfc_option.flag_range_check), array); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
build_int_cst (integer_type_node,
(gfc_option.rtcheck
& GFC_RTCHECK_BOUNDS)));
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
build_int_cst (integer_type_node,
gfc_option.flag_range_check));
array_type = build_array_type (integer_type_node, array_type = build_array_type (integer_type_node,
build_index_type (build_int_cst (NULL_TREE, 7))); build_index_type (build_int_cst (NULL_TREE, 7)));
array = build_constructor_from_list (array_type, nreverse (array)); array = build_constructor (array_type, v);
TREE_CONSTANT (array) = 1; TREE_CONSTANT (array) = 1;
TREE_STATIC (array) = 1; TREE_STATIC (array) = 1;
......
...@@ -1593,12 +1593,13 @@ gfc_trans_logical_select (gfc_code * code) ...@@ -1593,12 +1593,13 @@ gfc_trans_logical_select (gfc_code * code)
static tree static tree
gfc_trans_character_select (gfc_code *code) gfc_trans_character_select (gfc_code *code)
{ {
tree init, node, end_label, tmp, type, case_num, label, fndecl; tree init, end_label, tmp, type, case_num, label, fndecl;
stmtblock_t block, body; stmtblock_t block, body;
gfc_case *cp, *d; gfc_case *cp, *d;
gfc_code *c; gfc_code *c;
gfc_se se; gfc_se se;
int n, k; int n, k;
VEC(constructor_elt,gc) *inits = NULL;
/* The jump table types are stored in static variables to avoid /* The jump table types are stored in static variables to avoid
constructing them from scratch every single time. */ constructing them from scratch every single time. */
...@@ -1678,52 +1679,50 @@ gfc_trans_character_select (gfc_code *code) ...@@ -1678,52 +1679,50 @@ gfc_trans_character_select (gfc_code *code)
} }
/* Generate the structure describing the branches */ /* Generate the structure describing the branches */
init = NULL_TREE;
for(d = cp; d; d = d->right) for(d = cp; d; d = d->right)
{ {
node = NULL_TREE; VEC(constructor_elt,gc) *node = NULL;
gfc_init_se (&se, NULL); gfc_init_se (&se, NULL);
if (d->low == NULL) if (d->low == NULL)
{ {
node = tree_cons (ss_string1[k], null_pointer_node, node); CONSTRUCTOR_APPEND_ELT (node, ss_string1[k], null_pointer_node);
node = tree_cons (ss_string1_len[k], integer_zero_node, node); CONSTRUCTOR_APPEND_ELT (node, ss_string1_len[k], integer_zero_node);
} }
else else
{ {
gfc_conv_expr_reference (&se, d->low); gfc_conv_expr_reference (&se, d->low);
node = tree_cons (ss_string1[k], se.expr, node); CONSTRUCTOR_APPEND_ELT (node, ss_string1[k], se.expr);
node = tree_cons (ss_string1_len[k], se.string_length, node); CONSTRUCTOR_APPEND_ELT (node, ss_string1_len[k], se.string_length);
} }
if (d->high == NULL) if (d->high == NULL)
{ {
node = tree_cons (ss_string2[k], null_pointer_node, node); CONSTRUCTOR_APPEND_ELT (node, ss_string2[k], null_pointer_node);
node = tree_cons (ss_string2_len[k], integer_zero_node, node); CONSTRUCTOR_APPEND_ELT (node, ss_string2_len[k], integer_zero_node);
} }
else else
{ {
gfc_init_se (&se, NULL); gfc_init_se (&se, NULL);
gfc_conv_expr_reference (&se, d->high); gfc_conv_expr_reference (&se, d->high);
node = tree_cons (ss_string2[k], se.expr, node); CONSTRUCTOR_APPEND_ELT (node, ss_string2[k], se.expr);
node = tree_cons (ss_string2_len[k], se.string_length, node); CONSTRUCTOR_APPEND_ELT (node, ss_string2_len[k], se.string_length);
} }
node = tree_cons (ss_target[k], build_int_cst (integer_type_node, d->n), CONSTRUCTOR_APPEND_ELT (node, ss_target[k],
node); build_int_cst (integer_type_node, d->n));
tmp = build_constructor_from_list (select_struct[k], nreverse (node)); tmp = build_constructor (select_struct[k], node);
init = tree_cons (NULL_TREE, tmp, init); CONSTRUCTOR_APPEND_ELT (inits, NULL_TREE, tmp);
} }
type = build_array_type (select_struct[k], type = build_array_type (select_struct[k],
build_index_type (build_int_cst (NULL_TREE, n-1))); build_index_type (build_int_cst (NULL_TREE, n-1)));
init = build_constructor_from_list (type, nreverse(init)); init = build_constructor (type, inits);
TREE_CONSTANT (init) = 1; TREE_CONSTANT (init) = 1;
TREE_STATIC (init) = 1; TREE_STATIC (init) = 1;
/* Create a static variable to hold the jump table. */ /* Create a static variable to hold the jump table. */
......
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