From patchwork Tue Jul 18 15:18:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1809352 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=rb7Et0lT; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R53Kr4BRTz20FX for ; Wed, 19 Jul 2023 01:49:36 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4ED9D3856DE6 for ; Tue, 18 Jul 2023 15:49:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4ED9D3856DE6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689695374; bh=K11Nvo5VFQOaL9gjsjola3z6If3NOquWyO9CtmfgT1A=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=rb7Et0lTAB2FGchRO105IdKN7FyYxIozxmIr0QwCPJo1+K+77uqAEfbc4r1ZZPyoj eEqbmyB3PEK5oM7x02Xlkh6skD2hGGllof+Qt3vbJRlBMQJKWUW7hxbGq9gHO7xzlm 3T+NT3lqsrlnLkYHsXZyPFruNm6VbQV/9l7USL8U= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id DB85F385773C for ; Tue, 18 Jul 2023 15:49:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB85F385773C Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-672-OQz6FG38NKeDyszg4liqtg-1; Tue, 18 Jul 2023 11:18:14 -0400 X-MC-Unique: OQz6FG38NKeDyszg4liqtg-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-76752bc38bcso844278585a.2 for ; Tue, 18 Jul 2023 08:18:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689693490; x=1692285490; 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=K11Nvo5VFQOaL9gjsjola3z6If3NOquWyO9CtmfgT1A=; b=lqdlQgfYrH5Hfh5kzSwnOgayW1r5284bQ/l2UIX8mWTlQmA0alXa2XJYalIgSMVnTa j57K9sEcQ/Ar7dLY4Vs2/nlNc6RtGzca5Oe7lI9+d8sh4aOe/NPMcWpjeGgnwKozXOR7 L/3BoqclfwaCZ9TI0xjrwg4dlBY/lBRCLiFvHkXCqaMvQ0QHJSjtaw+KoAaE/GSMT/Pf GNAfHIVoZ6OB7rOc+m8P4JAlI47EZnsp6OSt0v2fANC7jTVlDm8wv9+EKFhRMNGbDzIl hYLbCEZdz/UdTFI1lO7F9sAJQv0JZe70/oJEus6AcmkffEVHfzhrHf8CJqr00zhKOydj HC6Q== X-Gm-Message-State: ABy/qLZ9RfaWdMcKdT4v5Ou+JkHF5kOePE05Zpu4oyEF00bSTYHXBPaf SV+MRETJ+iagj71RvofBsqi66l028Yv+7MFR/r13ZNpSHAY8gpL1DxWziIFDv/vLspbtbkusRKm FFTC6faMdRjHGdBoMYO+Cd+m6q9Zj5NCeM2liE4TRJIkKwRsbdZjWQwf71eP+R9Z+X7bq5qhkvS Y= X-Received: by 2002:a05:620a:3941:b0:768:2b02:d38 with SMTP id qs1-20020a05620a394100b007682b020d38mr3310629qkn.19.1689693489885; Tue, 18 Jul 2023 08:18:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlEnwOqGQxgATAIiA23htG5JCp0R8q+aNoY+U9luD+0fTlHtlQpcTUNR3qCxQqdIW22eaE1mUg== X-Received: by 2002:a05:620a:3941:b0:768:2b02:d38 with SMTP id qs1-20020a05620a394100b007682b020d38mr3310611qkn.19.1689693489595; Tue, 18 Jul 2023 08:18:09 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id pa39-20020a05620a832700b00767cd764ecfsm663247qkn.33.2023.07.18.08.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 08:18:09 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: deducing empty type vs non-type argument pack Date: Tue, 18 Jul 2023 11:18:07 -0400 Message-ID: <20230718151807.665487-1-ppalka@redhat.com> X-Mailer: git-send-email 2.41.0.363.g5e238546dc MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.7 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, T_SCC_BODY_TEXT_LINE 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" Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? Also verified by way of gcc_assert that we never see TEMPLATE_PARM_INDEX here. -- >8 -- Within a template parameter list, a non-type template parameter pack is represented as a PARM_DECL. But in a couple of spots where we need to deduce an empty argument pack, we test for TEMPLATE_PARM_INDEX (within a template parameter list) instead of for PARM_DECL, which means we end up using TYPE_ARGUMENT_PACK even in the non-type case. This patch fixes this (seemingly harmless) bug. gcc/cp/ChangeLog: * pt.cc (type_unification_real): Test for PARM_DECL instead of TEMPLATE_PARM_INDEX to distinguish a type vs non-type template parameter pack. (type_targs_deducible_from): Likewise. --- gcc/cp/pt.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 3987ffc509a..d342ab5929a 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -23345,7 +23345,7 @@ type_unification_real (tree tparms, { tree arg; - if (TREE_CODE (tparm) == TEMPLATE_PARM_INDEX) + if (TREE_CODE (tparm) == PARM_DECL) { arg = make_node (NONTYPE_ARGUMENT_PACK); TREE_CONSTANT (arg) = 1; @@ -30369,7 +30369,7 @@ type_targs_deducible_from (tree tmpl, tree type) if (template_parameter_pack_p (tparm)) { tree arg; - if (TREE_CODE (tparm) == TEMPLATE_PARM_INDEX) + if (TREE_CODE (tparm) == PARM_DECL) { arg = make_node (NONTYPE_ARGUMENT_PACK); TREE_CONSTANT (arg) = 1;