void genrtl_switch_stmt (tree t) { tree cond; genrtl_do_pushlevel (); cond = expand_cond (SWITCH_COND (t)); if (cond == error_mark_node) /* The code is in error, but we don't want expand_end_case to crash. */ cond = truthvalue_false_node; emit_line_note (input_location); expand_start_case (1, cond, TREE_TYPE (cond), "switch statement"); expand_stmt (expand_unreachable_stmt (SWITCH_BODY (t), warn_notreached)); expand_end_case_type (cond, SWITCH_TYPE (t)); }
static enum gimplify_status gimplify_switch_stmt (tree *stmt_p) { tree stmt = *stmt_p; tree break_block, body; location_t stmt_locus = input_location; break_block = begin_bc_block (bc_break); body = SWITCH_BODY (stmt); if (!body) body = build_empty_stmt (); *stmt_p = build3 (SWITCH_EXPR, SWITCH_TYPE (stmt), SWITCH_COND (stmt), body, NULL_TREE); SET_EXPR_LOCATION (*stmt_p, stmt_locus); gimplify_stmt (stmt_p); *stmt_p = finish_bc_block (break_block, *stmt_p); return GS_ALL_DONE; }
bool c_dump_tree (void *dump_info, tree t) { enum tree_code code; dump_info_p di = (dump_info_p) dump_info; /* Figure out what kind of node this is. */ code = TREE_CODE (t); switch (code) { case FIELD_DECL: if (DECL_C_BIT_FIELD (t)) dump_string (di, "bitfield"); break; case BREAK_STMT: case CONTINUE_STMT: dump_stmt (di, t); break; case DO_STMT: dump_stmt (di, t); dump_child ("body", DO_BODY (t)); dump_child ("cond", DO_COND (t)); break; case EXPR_STMT: dump_stmt (di, t); dump_child ("expr", EXPR_STMT_EXPR (t)); break; case FOR_STMT: dump_stmt (di, t); dump_child ("init", FOR_INIT_STMT (t)); dump_child ("cond", FOR_COND (t)); dump_child ("expr", FOR_EXPR (t)); dump_child ("body", FOR_BODY (t)); break; case SWITCH_STMT: dump_stmt (di, t); dump_child ("cond", SWITCH_COND (t)); dump_child ("body", SWITCH_BODY (t)); break; case WHILE_STMT: dump_stmt (di, t); dump_child ("cond", WHILE_COND (t)); dump_child ("body", WHILE_BODY (t)); break; case STMT_EXPR: dump_child ("stmt", STMT_EXPR_STMT (t)); break; default: break; } return false; }
void process_stmt (tree stmt) { tree_stmt_iterator si; switch (TREE_CODE(stmt)) { case STATEMENT_LIST: // this is a statement list printf("statement_list\n"); for (si = tsi_start (stmt); !tsi_end_p (si); tsi_next (&si)) { process_stmt(tsi_stmt(si)); } break; case BIND_EXPR: // this is a bind expression printf("bind_expr\n"); process_stmt((BIND_EXPR_BODY(stmt))); break; case DECL_EXPR: // this is a desclare expression printf("decl_expr\n"); num_statements++; num_local_var++; break; case MODIFY_EXPR: // this is a modify expression printf("modify_expr\n"); num_statements++; break; case CALL_EXPR: // this is a function call expression printf("call_expr\n"); num_statements++; break; case RETURN_EXPR: // this is a return value expression printf("return_expr\n"); num_statements++; break; case COND_EXPR: // this is a conditional branch expression printf("cond_expr\n"); tree then_node = COND_EXPR_THEN(stmt); tree else_node = COND_EXPR_ELSE(stmt); if (!(then_node && TREE_CODE(then_node) == GOTO_EXPR && !EXPR_HAS_LOCATION(then_node) && else_node && TREE_CODE(else_node) == GOTO_EXPR && !EXPR_HAS_LOCATION(else_node))) { num_statements++; } process_stmt(COND_EXPR_THEN(stmt)); if (COND_EXPR_ELSE(stmt)) process_stmt(COND_EXPR_ELSE(stmt)); break; case SWITCH_EXPR: // this is a switch branch expression printf("switch_expr\n"); num_statements++; process_stmt(SWITCH_BODY(stmt)); break; case CASE_LABEL_EXPR: // this is a case label expression printf("case_label_expr\n"); break; case GOTO_EXPR: // this is a jump expression printf("goto_expr\n"); // if (!DECL_IS_BUILTIN(GOTO_DESTINATION (stmt))) // num_statements++; if (EXPR_HAS_LOCATION(stmt)) { num_statements++; } break; case LABEL_EXPR: // this is a jump destination label expression printf("label_expr\n"); break; default: printf("default\n"); break; } // printf("number of statements: %d\n", num_statements); }