Message ID | 20170817102905.GG17069@redhat.com |
---|---|
State | New |
Headers | show |
On Thu, 17 Aug 2017, Marek Polacek wrote: > I've been itching to remove this code for some time now. The comment suggests > that the code is actually unused, so I replaced the body of that "else if" with > gcc_unreachable (); and ran regtest/bootstrap and nothing broke, so I propose > to do away with it. > > Bootstrapped/regtested on x86_64-linux, ok for trunk? OK, with an appropriate change to the comment above the c_parser_postfix_expression function to say that compound literals are not handled here and callers have to call c_parser_postfix_expression_after_paren_type on encountering them. (I've reviewed all paths to c_parser_postfix_expression in the current parser and don't think any of them can send compound literals to it, because either they are parsing a specific more restricted syntax incompatible with compond literals (OMP cases), are parsing an expression that might be a cast expression so need to parse the (type) first to distinguish, or are parsing a context such as sizeof where a parenthesized type name is allowed as well as a postfix expression and again need to parse the (type) first to distinguish.)
diff --git gcc/c/c-parser.c gcc/c/c-parser.c index 1402ba67204..8511a8b4fe7 100644 --- gcc/c/c-parser.c +++ gcc/c/c-parser.c @@ -7943,28 +7943,6 @@ c_parser_postfix_expression (c_parser *parser) set_c_expr_source_range (&expr, loc, close_loc); mark_exp_read (expr.value); } - else if (c_token_starts_typename (c_parser_peek_2nd_token (parser))) - { - /* A compound literal. ??? Can we actually get here rather - than going directly to - c_parser_postfix_expression_after_paren_type from - elsewhere? */ - location_t loc; - struct c_type_name *type_name; - c_parser_consume_token (parser); - loc = c_parser_peek_token (parser)->location; - type_name = c_parser_type_name (parser); - c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, - "expected %<)%>"); - if (type_name == NULL) - { - expr.set_error (); - } - else - expr = c_parser_postfix_expression_after_paren_type (parser, - type_name, - loc); - } else { /* A parenthesized expression. */