On Thu, 7 Nov 2024, Marek Polacek wrote: > @@ -8355,7 +8492,9 @@ c_parser_switch_statement (c_parser *parser, bool > *if_p, tree before_labels) > if (c_parser_next_token_is (parser, CPP_OPEN_PAREN) > && c_token_starts_typename (c_parser_peek_2nd_token (parser))) > explicit_cast_p = true; > - ce = c_parser_expression (parser); > + ce = c_parser_selection_header (parser, /*switch_p=*/true); > + /* The call above already performed convert_lvalue_to_rvalue, but with > + read_p=false. */ > ce = convert_lvalue_to_rvalue (switch_cond_loc, ce, true, true);
That comment only seems accurate in the case of an expression; in the case of a simple-declaration, read_p=true for the previous call. I think there's another case of invalid code it would be good to add tests for. You have tests in c2y-if-decls-6.c of valid code with a VLA in in if/switch declaration. It would be good to test also the invalid case where there is a jump into the scope of such an identifier with VM type (whether with goto, or with an outer switch around an if statement with such a declaration), to verify that the checks for this do work in both the declaration and the simple-declaration cases of if and switch. -- Joseph S. Myers josmy...@redhat.com