From patchwork Mon May 21 19:47:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 917823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-478102-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SN2wQsBn"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40qTqf71TWz9s1b for ; Tue, 22 May 2018 05:49:01 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=iA699Lz2y4p89qKLWN1X6XbcGpMhAI0Ori/HsR+WQZZBDsnLnH QoShQHaxx/hjtG4IxM9PQiiG84p411CZmdU0XJl4KeWpTT5OBISO86o0RaV3PTr9 wLffijVK0d7AtrCKydWUk5Zf2wnH6N3OilfNVyXvJVy2ZxtgbmNQ8gVVA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=ZmSqBsp8LYy+k6mCMZ59D90F0jM=; b=SN2wQsBn9vWzuI/cOQqs TUgYXvbj6HheD+ruYwFM7fFf+IFXrQerKOvO0CojZIPETdGe4f+gMeWkcmuihRpb EJJcoVDq9ZJVTQxWuPLgFd45wf5B5e81+RYmi7BsRqB+LMMuwcNiYP953NhG/96w 8svzq7JzgHGvIz0Rwiu94Io= Received: (qmail 111314 invoked by alias); 21 May 2018 19:48:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 111056 invoked by uid 89); 21 May 2018 19:48:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.9 required=5.0 tests=BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=considerations, Upon X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 May 2018 19:48:24 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4LJjZwP178644; Mon, 21 May 2018 19:48:05 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2j2bw85r1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 May 2018 19:48:05 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w4LJm46v019511 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 May 2018 19:48:04 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w4LJm3VA020098; Mon, 21 May 2018 19:48:03 GMT Received: from [192.168.1.4] (/95.235.218.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 21 May 2018 12:48:03 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Remove cp_parser_parameter_declaration_list parameter Message-ID: Date: Mon, 21 May 2018 21:47:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8900 signatures=668700 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805210235 X-IsSubscribed: yes Hi, I noticed a few days ago that the second parameter of the function is redundant, we can just rely on the return value possibly being error_mark_node (I even ran the testsuite with the function instrumented with a gcc_assert (*is_error == (parameters == error_mark_node); immediately before the return, at some point). Tested x86_64-linux. Thanks, Paolo. //////////////////// 2018-05-21 Paolo Carlini * parser.c (cp_parser_parameter_declaration_list): Remove bool* parameter. (cp_parser_parameter_declaration_clause): Adjust. (cp_parser_cache_defarg): Likewise. Index: parser.c =================================================================== --- parser.c (revision 260280) +++ parser.c (working copy) @@ -2235,7 +2235,7 @@ static void cp_parser_type_specifier_seq static tree cp_parser_parameter_declaration_clause (cp_parser *); static tree cp_parser_parameter_declaration_list - (cp_parser *, bool *); + (cp_parser *); static cp_parameter_declarator *cp_parser_parameter_declaration (cp_parser *, bool, bool *); static tree cp_parser_default_argument @@ -21191,7 +21209,6 @@ cp_parser_parameter_declaration_clause (cp_parser* tree parameters; cp_token *token; bool ellipsis_p; - bool is_error; temp_override cleanup (parser->auto_is_implicit_function_template_parm_p); @@ -21239,12 +21256,12 @@ cp_parser_parameter_declaration_clause (cp_parser* } /* Parse the parameter-declaration-list. */ - parameters = cp_parser_parameter_declaration_list (parser, &is_error); + parameters = cp_parser_parameter_declaration_list (parser); /* If a parse error occurred while parsing the parameter-declaration-list, then the entire parameter-declaration-clause is erroneous. */ - if (is_error) - return NULL; + if (parameters == error_mark_node) + return NULL_TREE; /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); @@ -21284,11 +21301,10 @@ cp_parser_parameter_declaration_clause (cp_parser* Returns a representation of the parameter-declaration-list, as for cp_parser_parameter_declaration_clause. However, the - `void_list_node' is never appended to the list. Upon return, - *IS_ERROR will be true iff an error occurred. */ + `void_list_node' is never appended to the list. */ static tree -cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error) +cp_parser_parameter_declaration_list (cp_parser* parser) { tree parameters = NULL_TREE; tree *tail = ¶meters; @@ -21295,8 +21311,6 @@ static tree bool saved_in_unbraced_linkage_specification_p; int index = 0; - /* Assume all will go well. */ - *is_error = false; /* The special considerations that apply to a function within an unbraced linkage specifications do not apply to the parameters to the function. */ @@ -21338,7 +21352,6 @@ static tree then the entire parameter-declaration-list is erroneous. */ if (decl == error_mark_node) { - *is_error = true; parameters = error_mark_node; break; } @@ -28958,7 +28971,9 @@ cp_parser_cache_defarg (cp_parser *parser, bool ns { cp_lexer_consume_token (parser->lexer); begin_scope (sk_function_parms, NULL_TREE); - cp_parser_parameter_declaration_list (parser, &error); + if (cp_parser_parameter_declaration_list (parser) + == error_mark_node) + error = true; pop_bindings_and_leave_scope (); } if (!cp_parser_error_occurred (parser) && !error)