@@ -1659,22 +1659,7 @@ static NODE *add_block_exit(struct parser_params *p, NODE *node);
16591659static rb_node_exits_t *init_block_exit(struct parser_params *p);
16601660static rb_node_exits_t *allow_block_exit(struct parser_params *p);
16611661static void restore_block_exit(struct parser_params *p, rb_node_exits_t *exits);
1662- static void clear_block_exit(struct parser_params *p, unsigned int error_mask);
1663-
1664- static unsigned int
1665- exits_mask(enum node_type t)
1666- {
1667- switch (t) {
1668- case NODE_BREAK:
1669- case NODE_NEXT:
1670- case NODE_REDO:
1671- return 1u << (t - NODE_BREAK);
1672- default:
1673- UNREACHABLE_RETURN(0);
1674- }
1675- }
1676-
1677- #define EXITS_MASK_ALL (exits_mask(NODE_BREAK)|exits_mask(NODE_NEXT)|exits_mask(NODE_REDO))
1662+ static void clear_block_exit(struct parser_params *p, bool error);
16781663
16791664static void
16801665next_rescue_context(struct lex_context *next, const struct lex_context *outer, enum rescue_context def)
@@ -1692,7 +1677,7 @@ restore_defun(struct parser_params *p, rb_node_def_temp_t *temp)
16921677 p->ctxt.in_rescue = ctxt.in_rescue;
16931678 p->max_numparam = temp->save.max_numparam;
16941679 numparam_pop(p, temp->save.numparam_save);
1695- clear_block_exit(p, EXITS_MASK_ALL );
1680+ clear_block_exit(p, true );
16961681}
16971682
16981683static void
@@ -1849,23 +1834,20 @@ restore_block_exit(struct parser_params *p, rb_node_exits_t *exits)
18491834}
18501835
18511836static void
1852- clear_block_exit(struct parser_params *p, unsigned int error_mask )
1837+ clear_block_exit(struct parser_params *p, bool error )
18531838{
18541839 rb_node_exits_t *exits = p->exits;
18551840 if (!exits) return;
1856- if (error_mask ) {
1841+ if (error ) {
18571842 for (NODE *e = RNODE(exits); (e = RNODE_EXITS(e)->nd_chain) != 0; ) {
18581843 switch (nd_type(e)) {
18591844 case NODE_BREAK:
1860- if (!(error_mask & exits_mask(NODE_BREAK))) break;
18611845 yyerror1(&e->nd_loc, "Invalid break");
18621846 break;
18631847 case NODE_NEXT:
1864- if (!(error_mask & exits_mask(NODE_NEXT))) break;
18651848 yyerror1(&e->nd_loc, "Invalid next");
18661849 break;
18671850 case NODE_REDO:
1868- if (!(error_mask & exits_mask(NODE_REDO))) break;
18691851 yyerror1(&e->nd_loc, "Invalid redo");
18701852 break;
18711853 default:
@@ -3230,7 +3212,7 @@ top_stmts : none
32303212
32313213top_stmt : stmt
32323214 {
3233- clear_block_exit(p, EXITS_MASK_ALL );
3215+ clear_block_exit(p, true );
32343216 $$ = $1;
32353217 }
32363218 | keyword_BEGIN begin_block
@@ -3370,7 +3352,7 @@ stmt : keyword_alias[kw] fitem[new] {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fit
33703352 }
33713353 | stmt[body] modifier_while[mod] expr_value[cond_expr]
33723354 {
3373- clear_block_exit(p, 0 );
3355+ clear_block_exit(p, false );
33743356 if ($body && nd_type_p($body, NODE_BEGIN)) {
33753357 $$ = NEW_WHILE(cond(p, $cond_expr, &@cond_expr), RNODE_BEGIN($body)->nd_body, 0, &@$, &@mod, &NULL_LOC);
33763358 }
@@ -3401,7 +3383,7 @@ stmt : keyword_alias[kw] fitem[new] {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fit
34013383 }
34023384 | k_END[k_end] block_open[lbrace] compstmt(stmts)[body] '}'[rbrace]
34033385 {
3404- clear_block_exit(p, exits_mask(NODE_BREAK) | exits_mask(NODE_REDO) );
3386+ clear_block_exit(p, true );
34053387 restore_block_exit(p, $block_open);
34063388 p->ctxt = $k_end;
34073389 {
0 commit comments