This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix location of typeid() (PR c++/80014)
- From: Jason Merrill <jason at redhat dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 15 Mar 2017 16:35:14 -0400
- Subject: Re: [PATCH] Fix location of typeid() (PR c++/80014)
- Authentication-results: sourceware.org; auth=none
- References: <1489539903-13119-1-git-send-email-dmalcolm@redhat.com>
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