Simplify case_label_to_firm() a bit, which can be done since new_immBlock() does...
[cparser] / ast2firm.c
index 829a4d2..a7d60dd 100644 (file)
@@ -4982,18 +4982,13 @@ static void while_statement_to_firm(while_statement_t *statement)
 
 static void do_while_statement_to_firm(do_while_statement_t *statement)
 {
-       ir_node *jmp = NULL;
-       if (get_cur_block() != NULL) {
-               jmp = new_Jmp();
-       }
-
        /* create the header block */
        ir_node *header_block = new_immBlock();
 
        /* the loop body */
        ir_node *body_block = new_immBlock();
-       if (jmp != NULL) {
-               add_immBlock_pred(body_block, jmp);
+       if (get_cur_block() != NULL) {
+               add_immBlock_pred(body_block, new_Jmp());
        }
 
        ir_node *old_continue_label = continue_label;
@@ -5221,9 +5216,7 @@ static void switch_statement_to_firm(switch_statement_t *statement)
                set_Cond_default_proj(cond, default_proj_nr);
        }
 
-       if (statement->body != NULL) {
-               statement_to_firm(statement->body);
-       }
+       statement_to_firm(statement->body);
 
        if (get_cur_block() != NULL) {
                ir_node *jmp = new_Jmp();
@@ -5255,11 +5248,14 @@ static void case_label_to_firm(const case_label_statement_t *statement)
 
        dbg_info *dbgi = get_dbg_info(&statement->base.source_position);
 
-       ir_node *const fallthrough = (get_cur_block() == NULL ? NULL : new_Jmp());
-
        ir_node *proj;
        ir_node *block = new_immBlock();
 
+       if (get_cur_block() != NULL) {
+               /* Fallthrough from previous case */
+               add_immBlock_pred(block, new_Jmp());
+       }
+
        if (current_switch_cond != NULL) {
                set_cur_block(get_nodes_block(current_switch_cond));
                if (statement->expression != NULL) {
@@ -5280,15 +5276,10 @@ static void case_label_to_firm(const case_label_statement_t *statement)
                }
        }
 
-       if (fallthrough != NULL) {
-               add_immBlock_pred(block, fallthrough);
-       }
        mature_immBlock(block);
        set_cur_block(block);
 
-       if (statement->statement != NULL) {
-               statement_to_firm(statement->statement);
-       }
+       statement_to_firm(statement->statement);
 }
 
 static void label_to_firm(const label_statement_t *statement)
@@ -5304,9 +5295,7 @@ static void label_to_firm(const label_statement_t *statement)
        keep_alive(block);
        keep_all_memory(block);
 
-       if (statement->statement != NULL) {
-               statement_to_firm(statement->statement);
-       }
+       statement_to_firm(statement->statement);
 }
 
 static void goto_to_firm(const goto_statement_t *statement)