@@ -16193,7 +16193,7 @@ struct parser_ctx
1619316193 /*
1619416194 * Points to the selection_statement we're in. Or null.
1619516195 */
16196- struct selection_statement* _Opt p_current_selection_statement ;
16196+ struct selection_statement* _Opt p_current_switch_statement ;
1619716197 const struct iteration_statement* _Opt p_current_iteration_statement;
1619816198
1619916199
@@ -28720,7 +28720,7 @@ void defer_start_visit_declaration(struct defer_visit_ctx* ctx, struct declarati
2872028720
2872128721//#pragma once
2872228722
28723- #define CAKE_VERSION "0.12.67 "
28723+ #define CAKE_VERSION "0.12.68 "
2872428724
2872528725
2872628726
@@ -31051,8 +31051,8 @@ struct declaration* _Owner _Opt declaration(struct parser_ctx* ctx,
3105131051 struct defer_visit_ctx ctx2 = { .ctx = ctx };
3105231052 defer_start_visit_declaration(&ctx2, p_declaration);
3105331053 defer_visit_ctx_destroy(&ctx2);
31054-
31055-
31054+
31055+
3105631056 if (ctx->p_report->error_count == 0 && ctx->options.flow_analysis)
3105731057 {
3105831058 /*
@@ -37545,8 +37545,8 @@ struct label* _Owner _Opt label(struct parser_ctx* ctx, struct attribute_specifi
3754537545 else if (ctx->current->type == TK_KEYWORD_CASE)
3754637546 {
3754737547
37548- if (ctx->p_current_selection_statement == NULL ||
37549- ctx->p_current_selection_statement ->condition == NULL)
37548+ if (ctx->p_current_switch_statement == NULL ||
37549+ ctx->p_current_switch_statement ->condition == NULL)
3755037550 {
3755137551 //unexpected because we are in case
3755237552 compiler_diagnostic(C_ERROR_CASE_NOT_IN_SWITCH,
@@ -37584,7 +37584,7 @@ struct label* _Owner _Opt label(struct parser_ctx* ctx, struct attribute_specifi
3758437584 */
3758537585
3758637586 struct label* _Opt p_existing_label = case_label_list_find_range(ctx,
37587- &ctx->p_current_selection_statement ->label_list,
37587+ &ctx->p_current_switch_statement ->label_list,
3758837588 &p_label->constant_expression->object,
3758937589 &p_label->constant_expression_end->object);
3759037590
@@ -37614,7 +37614,10 @@ struct label* _Owner _Opt label(struct parser_ctx* ctx, struct attribute_specifi
3761437614 }
3761537615 else
3761637616 {
37617- struct label* _Opt p_existing_label = case_label_list_find(ctx, &ctx->p_current_selection_statement->label_list, &p_label->constant_expression->object);
37617+ struct label* _Opt p_existing_label =
37618+ case_label_list_find(ctx, &ctx->p_current_switch_statement->label_list, &p_label->constant_expression->object);
37619+
37620+
3761837621 if (p_existing_label)
3761937622 {
3762037623
@@ -37638,20 +37641,20 @@ struct label* _Owner _Opt label(struct parser_ctx* ctx, struct attribute_specifi
3763837641 if (parser_match_tk(ctx, ':') != 0)
3763937642 throw;
3764037643
37641- case_label_list_push(&ctx->p_current_selection_statement ->label_list, p_label);
37644+ case_label_list_push(&ctx->p_current_switch_statement ->label_list, p_label);
3764237645
37643- if (ctx->p_current_selection_statement &&
37644- ctx->p_current_selection_statement ->condition &&
37645- ctx->p_current_selection_statement ->condition->expression)
37646+ if (ctx->p_current_switch_statement &&
37647+ ctx->p_current_switch_statement ->condition &&
37648+ ctx->p_current_switch_statement ->condition->expression)
3764637649 {
37647- if (type_is_enum(&ctx->p_current_selection_statement ->condition->expression->type))
37650+ if (type_is_enum(&ctx->p_current_switch_statement ->condition->expression->type))
3764837651 {
3764937652 if (type_is_enum(&p_label->constant_expression->type))
3765037653 {
3765137654 check_diferent_enuns(ctx,
3765237655 p_label->constant_expression->first_token,
3765337656 p_label->constant_expression,
37654- ctx->p_current_selection_statement ->condition->expression,
37657+ ctx->p_current_switch_statement ->condition->expression,
3765537658 "mismatch in enumeration types");
3765637659 }
3765737660 else
@@ -37660,19 +37663,19 @@ struct label* _Owner _Opt label(struct parser_ctx* ctx, struct attribute_specifi
3766037663 }
3766137664 }
3766237665
37663- if (ctx->p_current_selection_statement == NULL)
37666+ if (ctx->p_current_switch_statement == NULL)
3766437667 {
3766537668 //unexpected because we have case inside switch
3766637669 throw;
3766737670 }
3766837671
3766937672 const struct enum_specifier* _Opt p_enum_specifier = NULL;
3767037673
37671- if (ctx->p_current_selection_statement ->condition &&
37672- ctx->p_current_selection_statement ->condition->expression &&
37673- ctx->p_current_selection_statement ->condition->expression->type.enum_specifier)
37674+ if (ctx->p_current_switch_statement ->condition &&
37675+ ctx->p_current_switch_statement ->condition->expression &&
37676+ ctx->p_current_switch_statement ->condition->expression->type.enum_specifier)
3767437677 {
37675- p_enum_specifier = get_complete_enum_specifier(ctx->p_current_selection_statement ->condition->expression->type.enum_specifier);
37678+ p_enum_specifier = get_complete_enum_specifier(ctx->p_current_switch_statement ->condition->expression->type.enum_specifier);
3767637679 }
3767737680
3767837681 if (p_enum_specifier)
@@ -37700,8 +37703,8 @@ struct label* _Owner _Opt label(struct parser_ctx* ctx, struct attribute_specifi
3770037703 }
3770137704 else if (ctx->current->type == TK_KEYWORD_DEFAULT)
3770237705 {
37703- if (ctx->p_current_selection_statement == NULL ||
37704- ctx->p_current_selection_statement ->condition == NULL)
37706+ if (ctx->p_current_switch_statement == NULL ||
37707+ ctx->p_current_switch_statement ->condition == NULL)
3770537708 {
3770637709 //unexpected because we are in case
3770737710 compiler_diagnostic(C_ERROR_CASE_NOT_IN_SWITCH,
@@ -37713,7 +37716,7 @@ struct label* _Owner _Opt label(struct parser_ctx* ctx, struct attribute_specifi
3771337716 throw;
3771437717 }
3771537718
37716- struct label* _Opt p_existing_default_label = case_label_list_find_default(ctx, &ctx->p_current_selection_statement ->label_list);
37719+ struct label* _Opt p_existing_default_label = case_label_list_find_default(ctx, &ctx->p_current_switch_statement ->label_list);
3771737720
3771837721 if (p_existing_default_label)
3771937722 {
@@ -37738,7 +37741,7 @@ struct label* _Owner _Opt label(struct parser_ctx* ctx, struct attribute_specifi
3773837741 if (parser_match_tk(ctx, ':') != 0)
3773937742 throw;
3774037743
37741- case_label_list_push(&ctx->p_current_selection_statement ->label_list, p_label);
37744+ case_label_list_push(&ctx->p_current_switch_statement ->label_list, p_label);
3774237745 }
3774337746 // attribute_specifier_sequence_opt identifier ':'
3774437747 // attribute_specifier_sequence_opt 'case' constant_expression ':'
@@ -38783,8 +38786,12 @@ struct selection_statement* _Owner _Opt selection_statement(struct parser_ctx* c
3878338786 }
3878438787 }
3878538788
38786- struct selection_statement* _Opt previous = ctx->p_current_selection_statement;
38787- ctx->p_current_selection_statement = p_selection_statement;
38789+ struct selection_statement* _Opt previous = ctx->p_current_switch_statement;
38790+
38791+ if (p_selection_statement->first_token->type == TK_KEYWORD_SWITCH)
38792+ {
38793+ ctx->p_current_switch_statement = p_selection_statement;
38794+ }
3878838795
3878938796 struct secondary_block* _Owner _Opt p_secondary_block = secondary_block(ctx);
3879038797
@@ -38810,7 +38817,7 @@ struct selection_statement* _Owner _Opt selection_statement(struct parser_ctx* c
3881038817 p_selection_statement->secondary_block = p_secondary_block;
3881138818
3881238819
38813- ctx->p_current_selection_statement = previous;
38820+ ctx->p_current_switch_statement = previous;
3881438821
3881538822
3881638823 if (is_if && ctx->current && ctx->current->type == TK_KEYWORD_ELSE)
@@ -39238,7 +39245,7 @@ struct jump_statement* _Owner _Opt jump_statement(struct parser_ctx* ctx)
3923839245 else if (ctx->current->type == TK_KEYWORD_BREAK)
3923939246 {
3924039247 const bool in_switch =
39241- ctx->p_current_selection_statement && ctx->p_current_selection_statement ->first_token->type == TK_KEYWORD_SWITCH;
39248+ ctx->p_current_switch_statement && ctx->p_current_switch_statement ->first_token->type == TK_KEYWORD_SWITCH;
3924239249
3924339250 if (ctx->p_current_iteration_statement == NULL && !in_switch)
3924439251 {
@@ -39807,8 +39814,8 @@ struct compound_statement* _Owner _Opt function_body(struct parser_ctx* ctx)
3980739814 const struct defer_statement* _Opt p_current_defer_statement_opt = ctx->p_current_defer_statement_opt;
3980839815 ctx->p_current_defer_statement_opt = NULL;
3980939816
39810- struct selection_statement* _Opt p_current_selection_statement = ctx->p_current_selection_statement ;
39811- ctx->p_current_selection_statement = NULL;
39817+ struct selection_statement* _Opt p_current_switch_statement = ctx->p_current_switch_statement ;
39818+ ctx->p_current_switch_statement = NULL;
3981239819
3981339820 struct label_list label_list = { 0 };
3981439821 label_list_swap(&label_list, &ctx->label_list);
@@ -39824,7 +39831,7 @@ struct compound_statement* _Owner _Opt function_body(struct parser_ctx* ctx)
3982439831 ctx->label_id = label_id;
3982539832 ctx->p_current_try_statement_opt = p_current_try_statement_opt;
3982639833 ctx->p_current_defer_statement_opt = p_current_defer_statement_opt;
39827- ctx->p_current_selection_statement = p_current_selection_statement ;
39834+ ctx->p_current_switch_statement = p_current_switch_statement ;
3982839835
3982939836 label_list_clear(&label_list);
3983039837
0 commit comments