From patchwork Fri Aug 25 17:41:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1826238 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=mkUyF9O2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RXS2K2SWXz1yfK for ; Sat, 26 Aug 2023 03:42:15 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F3BFF385841F for ; Fri, 25 Aug 2023 17:42:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F3BFF385841F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692985333; bh=OHqdu50r4vG+pukv99sZZmAWFd/VKWj39W/WEsjG/UA=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=mkUyF9O2fePyzHGTz3HT3IFkWoMcIaI55uNm9Dh5mk2kwXezcIuh58llzLoVHHMzJ JG334QUZ8hDR+qY1AELSZO0A0mpjNeTxOK3f/4+8BTDjYgtm45c9jBspGfkmmdLWmY XIPG/DAvpGllI3AWaudnwO21v/7sujje6VJHUieQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CF2E73858D37 for ; Fri, 25 Aug 2023 17:41:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CF2E73858D37 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-V-jwk2c4NFqoFUiMuugnFg-1; Fri, 25 Aug 2023 13:41:51 -0400 X-MC-Unique: V-jwk2c4NFqoFUiMuugnFg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-5eee6742285so13581996d6.2 for ; Fri, 25 Aug 2023 10:41:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692985310; x=1693590110; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OHqdu50r4vG+pukv99sZZmAWFd/VKWj39W/WEsjG/UA=; b=DBqYdkK0StKvWML+QaQxmEcar4e2JNOYcaV74wLYV20RLoAjl5TEnlQmDfzHVh6Ddb rx6XKJDDDofolplMdNJvYcu7ln33EoarO5JgNgaIOGnioyl0ltX2ZclC8u5k5p0aOE8p lPFb56YCPdmsBcV5ujqSC+SLYokrRX47oo0X6/ejrhjo6/wVxrYnH/AbZUIu2NAapJi5 JA8rQMJou0BcYZ0LG802589+vyGiHdB73FnWSgtthmH8RLnN6xV/6GvPYriRMgtT7i1D nE94ySd5eVgCaCLuqzPAW9APsE6/DVLeMlEzwEj0G+7X/64+5K+KzajzQxbjX5V/ADkT fITA== X-Gm-Message-State: AOJu0YzjNEiaSr3hMd8c2CIaUWHiuufyDisVA1UTojSJzZ2wmDiCFb3B WZoABhWiaTflv7MOS4uSulTGKRTjS/qoTSB5WfUcyVdHD0Sh8MgGwbxkgKpdAVTt4+c+Lu98Q4g GXzU6zMBFNWWJxCnemh6n3Ca7wrXLKaNOgnY37De0/d7mn/AcZUtjheonukP00dIngaaul8aBRN w= X-Received: by 2002:a0c:dc12:0:b0:64b:fdf0:48a3 with SMTP id s18-20020a0cdc12000000b0064bfdf048a3mr20344460qvk.10.1692985310657; Fri, 25 Aug 2023 10:41:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyz+51fzHZc4qhHmMDMIkGvktlBsxqWkYBMnFUFk6tvMxTR2yD4fIHj2lliz4YyP+YvvYh6w== X-Received: by 2002:a0c:dc12:0:b0:64b:fdf0:48a3 with SMTP id s18-20020a0cdc12000000b0064bfdf048a3mr20344438qvk.10.1692985310191; Fri, 25 Aug 2023 10:41:50 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id i6-20020a0cf486000000b00631ecb1052esm700592qvm.74.2023.08.25.10.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Aug 2023 10:41:48 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, mpolacek@redhat.com, Patrick Palka Subject: [PATCH] c++: more dummy non_constant_p arg avoidance Date: Fri, 25 Aug 2023 13:41:45 -0400 Message-ID: <20230825174146.3372968-1-ppalka@redhat.com> X-Mailer: git-send-email 2.42.0.29.gcd9da15a85 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Tested on x86_64-pc-linux-gnu, does this look OK for trunk? This reduces calls to is_rvalue_constant_expression from cp_parser_constant_expression by 10% for stdc++.h. -- >8 -- As a follow-up to Marek's r14-3088-ga263152643bbec, this patch makes us avoid passing an effectively dummy non_constant_p argument in two more spots in the parser. gcc/cp/ChangeLog: * parser.cc (cp_parser_parenthesized_expression_list_elt): Pass nullptr as non_constant_p to cp_parser_braced_list if our non_constant_p is null. (cp_parser_initializer_list): Likewise to cp_parser_initializer_clause. --- gcc/cp/parser.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 774706ac607..a8cc91059c1 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -8099,7 +8099,10 @@ cp_parser_parenthesized_expression_list_elt (cp_parser *parser, bool cast_p, /* A braced-init-list. */ cp_lexer_set_source_position (parser->lexer); maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); - expr = cp_parser_braced_list (parser, &expr_non_constant_p); + expr = cp_parser_braced_list (parser, + (non_constant_p != nullptr + ? &expr_non_constant_p + : nullptr)); if (non_constant_p && expr_non_constant_p) *non_constant_p = true; } @@ -25812,9 +25815,11 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p, /* Parse the initializer. */ initializer = cp_parser_initializer_clause (parser, - &clause_non_constant_p); + (non_constant_p != nullptr + ? &clause_non_constant_p + : nullptr)); /* If any clause is non-constant, so is the entire initializer. */ - if (clause_non_constant_p && non_constant_p) + if (non_constant_p && clause_non_constant_p) *non_constant_p = true; /* If we have an ellipsis, this is an initializer pack