This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
conditional LABEL_EXPR
- From: Philip Herron <redbrain at gcc dot gnu dot org>
- To: GCC <gcc-help at gcc dot gnu dot org>
- Date: Tue, 9 Oct 2012 12:47:06 +0100
- Subject: conditional LABEL_EXPR
Hey
I have been on and off trying to figure out in my front-end how to use
labels. Never seem to get them to work say i have the code:
bool x;
...
if (x == true)
{
do more stuff here
}
How do i create this so far i have:
tree label_decl = create_artificial_label (UNKNOWN_LOCATION);
tree label_expr = fold_build1_loc (UNKNOWN_LOCATION, LABEL_EXPR,
void_type_node, label_decl);
tree label_exit_decl = ...
tree label_exit_expr
tree conditional = fold_build2_loc (UNKNOWN_LOCATION, EQ_EXPR,
boolean_type_node,
if_cond_tree, boolean_true_node);
tree if_cond = build3_loc (UNKNOWN_LOCATION, COND_EXPR, void_type_node,
if_cond_tree,
build1 (GOTO_EXPR, void_type_node, label_expr),
build1 (GOTO_EXPR, void_type_node, label_exit_expr));
append_to_statement_list (if_cond, stmts);
append_to_statement_list (label_expr, stmts);
gpy_dot_pass_genericify_suite (ifblock_suite, stmts, context);
appent_to_statement_list (labe_exit_expr, stmts);
But i get:
<built-in>: In function ‘decr.py.test’:
<built-in>:0:0: internal compiler error: in gimplify_expr, at gimplify.c:7157
Please submit a full bug report,
And the asset is:
case LABEL_EXPR:
ret = GS_ALL_DONE;
gcc_assert (decl_function_context (LABEL_EXPR_LABEL (*expr_p))
== current_function_decl);
gimplify_seq_add_stmt (pre_p,
gimple_build_label (LABEL_EXPR_LABEL (*expr_p)));
break;
I can't see a good example on how to make an if statement hard to dig
through front-end specifics. I wonder does this mean for every
LABEL_EXPR it was DECL_CONTEXT(label) = current_fndecl?
--Phil