This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix location of typeid() (PR c++/80014)


On Tue, Mar 14, 2017 at 9:05 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> OK for trunk now, or should this wait until stage 1?

Stage 1.

> +       cp_token *close_paren = cp_parser_require (parser, CPP_CLOSE_PAREN,
> +                                                  RT_CLOSE_PAREN);
> +       location_t end_loc = close_paren ?
> +         close_paren->location : UNKNOWN_LOCATION;
>         /* If all went well, simply lookup the type-id.  */
>         if (cp_parser_parse_definitely (parser))
>           postfix_expression = get_typeid (type, tf_warning_or_error);
> @@ -6527,13 +6530,23 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
>             /* Compute its typeid.  */
>             postfix_expression = build_typeid (expression, tf_warning_or_error);
>             /* Look for the `)' token.  */
> -           cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
> +           close_paren
> +             = cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
> +           end_loc = close_paren ? close_paren->location : UNKNOWN_LOCATION;

In both cases you're setting end_loc from close_paren, so how about
only computing it once, closer to where it's used?

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]