trans-decl.c (gfc_build_label_decl): Set DECL_ARTIFICAL and TREE_USED for all labels.

* trans-decl.c (gfc_build_label_decl): Set DECL_ARTIFICAL and
	TREE_USED for all labels.
	(gfc_trans_entry_master_switch): Use it instead of building a
	label by hand.
	* trans-io.c (add_case): Likewise.
	* trans-stmt.c (gfc_trans_integer_select): Likewise.

From-SVN: r94299
This commit is contained in:
Steven Bosscher 2005-01-27 00:58:11 +00:00 committed by Steven Bosscher
parent 2f0a3aa2db
commit c006df4eec
4 changed files with 21 additions and 23 deletions

View File

@ -1,3 +1,12 @@
2004-01-27 Steven Bosscher <stevenb@suse.de>
* trans-decl.c (gfc_build_label_decl): Set DECL_ARTIFICAL and
TREE_USED for all labels.
(gfc_trans_entry_master_switch): Use it instead of building a
label by hand.
* trans-io.c (add_case): Likewise.
* trans-stmt.c (gfc_trans_integer_select): Likewise.
2004-01-23 Paul Brook <paul@codesourcery.com> 2004-01-23 Paul Brook <paul@codesourcery.com>
Steven G. Kargl <kargls@comcast.net> Steven G. Kargl <kargls@comcast.net>

View File

@ -148,9 +148,9 @@ gfc_add_decl_to_function (tree decl)
} }
/* Build a backend label declaration. /* Build a backend label declaration. Set TREE_USED for named labels.
Set TREE_USED for named lables. For artificial labels it's up to the The context of the label is always the current_function_decl. All
caller to mark the label as used. */ labels are marked artificial. */
tree tree
gfc_build_label_decl (tree label_id) gfc_build_label_decl (tree label_id)
@ -174,19 +174,13 @@ gfc_build_label_decl (tree label_id)
DECL_CONTEXT (label_decl) = current_function_decl; DECL_CONTEXT (label_decl) = current_function_decl;
DECL_MODE (label_decl) = VOIDmode; DECL_MODE (label_decl) = VOIDmode;
if (label_name)
{
DECL_ARTIFICIAL (label_decl) = 1;
}
else
{
/* We always define the label as used, even if the original source /* We always define the label as used, even if the original source
file never references the label. We don't want all kinds of file never references the label. We don't want all kinds of
spurious warnings for old-style Fortran code with too many spurious warnings for old-style Fortran code with too many
labels. */ labels. */
TREE_USED (label_decl) = 1; TREE_USED (label_decl) = 1;
}
DECL_ARTIFICIAL (label_decl) = 1;
return label_decl; return label_decl;
} }
@ -2122,16 +2116,13 @@ gfc_trans_entry_master_switch (gfc_entry_list * el)
for (; el; el = el->next) for (; el; el = el->next)
{ {
/* Add the case label. */ /* Add the case label. */
label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); label = gfc_build_label_decl (NULL_TREE);
DECL_CONTEXT (label) = current_function_decl;
val = build_int_cst (gfc_array_index_type, el->id); val = build_int_cst (gfc_array_index_type, el->id);
tmp = build3_v (CASE_LABEL_EXPR, val, NULL_TREE, label); tmp = build3_v (CASE_LABEL_EXPR, val, NULL_TREE, label);
gfc_add_expr_to_block (&block, tmp); gfc_add_expr_to_block (&block, tmp);
/* And jump to the actual entry point. */ /* And jump to the actual entry point. */
label = gfc_build_label_decl (NULL_TREE); label = gfc_build_label_decl (NULL_TREE);
TREE_USED (label) = 1;
DECL_CONTEXT (label) = current_function_decl;
tmp = build1_v (GOTO_EXPR, label); tmp = build1_v (GOTO_EXPR, label);
gfc_add_expr_to_block (&block, tmp); gfc_add_expr_to_block (&block, tmp);

View File

@ -452,8 +452,7 @@ add_case (int label_value, gfc_st_label * label, stmtblock_t * body)
value = build_int_cst (NULL_TREE, label_value); value = build_int_cst (NULL_TREE, label_value);
/* Make a backend label for this case. */ /* Make a backend label for this case. */
tmp = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); tmp = gfc_build_label_decl (NULL_TREE);
DECL_CONTEXT (tmp) = current_function_decl;
/* And the case itself. */ /* And the case itself. */
tmp = build3_v (CASE_LABEL_EXPR, value, NULL_TREE, tmp); tmp = build3_v (CASE_LABEL_EXPR, value, NULL_TREE, tmp);

View File

@ -945,8 +945,7 @@ gfc_trans_integer_select (gfc_code * code)
} }
/* Build a label. */ /* Build a label. */
label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE); label = gfc_build_label_decl (NULL_TREE);
DECL_CONTEXT (label) = current_function_decl;
/* Add this case label. /* Add this case label.
Add parameter 'label', make it match GCC backend. */ Add parameter 'label', make it match GCC backend. */