From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19911 invoked by alias); 8 Aug 2017 20:49:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 19898 invoked by uid 89); 8 Aug 2017 20:49:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Aug 2017 20:49:34 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 852616146C; Tue, 8 Aug 2017 20:49:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 852616146C Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dmalcolm@redhat.com Received: from c64.redhat.com (ovpn-112-37.phx2.redhat.com [10.3.112.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 589575DD65; Tue, 8 Aug 2017 20:49:32 +0000 (UTC) From: David Malcolm To: Jason Merrill , gcc-patches@gcc.gnu.org Cc: Trevor Saunders , David Malcolm Subject: [PATCH] Changes for v3 of the C++ patch Date: Tue, 08 Aug 2017 20:49:00 -0000 Message-Id: <1502227472-9580-1-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1502226094-9282-1-git-send-email-dmalcolm@redhat.com> References: <1502226094-9282-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00629.txt.bz2 For reference, here's the diff of the v3 C++ patch to the v2 patch, in case it's useful: gcc/cp/ChangeLog: * parser.c (token_pair::require_open): Use tabs rather than spaces. (token_pair::peek_open): Delete. (token_pair::require_close): Use tabs rather than spaces. (cp_parser_compound_literal_p): Remove consumption of opening paren. (cp_parser_postfix_expression): Add matching_parens instance. Use it to consume the opening paren previously consumed by cp_parser_compound_literal_p. Convert call to cp_parser_require to parens.require_close. (cp_parser_sizeof_operand): Convert call to parens.peek_open to call to consume_open to consume the opening paren previously consumed by cp_parser_compound_literal_p. --- gcc/cp/parser.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3037ac7..0da92ab 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -4527,7 +4527,7 @@ class token_pair { m_open_loc = cp_lexer_peek_token (parser->lexer)->location; return cp_parser_require (parser, traits_t::open_token_type, - traits_t::required_token_open); + traits_t::required_token_open); } /* Consume the next token from PARSER, recording its location as @@ -4541,16 +4541,6 @@ class token_pair return tok; } - /* Peek the next token from PARSER, recording its location as - that of the opening token within the pair. */ - - void peek_open (cp_parser *parser) - { - cp_token *tok = cp_lexer_peek_token (parser->lexer); - gcc_assert (tok->type == traits_t::open_token_type); - m_open_loc = tok->location; - } - /* If the next token is the closing symbol for this pair, consume it and return it. Otherwise, issue an error, highlighting the location of the @@ -4559,8 +4549,8 @@ class token_pair cp_token *require_close (cp_parser *parser) const { return cp_parser_require (parser, traits_t::close_token_type, - traits_t::required_token_close, - m_open_loc); + traits_t::required_token_close, + m_open_loc); } private: @@ -6443,9 +6433,6 @@ cp_parser_qualifying_entity (cp_parser *parser, static bool cp_parser_compound_literal_p (cp_parser *parser) { - /* Consume the `('. */ - cp_lexer_consume_token (parser->lexer); - cp_lexer_save_tokens (parser->lexer); /* Skip tokens until the next token is a closing parenthesis. @@ -6857,6 +6844,9 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, cp_parser_parse_tentatively (parser); + matching_parens parens; + parens.consume_open (parser); + /* Avoid calling cp_parser_type_id pointlessly, see comment in cp_parser_cast_expression about c++/29234. */ if (!cp_parser_compound_literal_p (parser)) @@ -6868,8 +6858,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, parser->in_type_id_in_expr_p = true; type = cp_parser_type_id (parser); parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p; - /* Look for the `)'. */ - cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN); + parens.require_close (parser); } /* If things aren't going well, there's no need to @@ -27773,12 +27762,13 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword) { tree type = NULL_TREE; - matching_parens parens; - parens.peek_open (parser); - /* We can't be sure yet whether we're looking at a type-id or an expression. */ cp_parser_parse_tentatively (parser); + + matching_parens parens; + parens.consume_open (parser); + /* Note: as a GNU Extension, compound literals are considered postfix-expressions as they are in C99, so they are valid arguments to sizeof. See comment in cp_parser_cast_expression -- 1.8.5.3