From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689695354; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=K11Nvo5VFQOaL9gjsjola3z6If3NOquWyO9CtmfgT1A=; b=Z3DW5E0O3iXhw2V2ha6HItqMowCu4abIGlwz1Rn+zeRpqbFiPZAjbwJIDwufRRe54Uljxp kWut/jpKtQzWAdIXCGi0AYJJdOc6440ceRx/+qS5Q+PckJtWbg5A+aK9hZ3sQyr13jB5mC j4GdQOQsTTJxrnJqBbH1uqr4v0IoaV8= 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) From: Patrick Palka 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 List-Id: 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; -- 2.41.0.363.g5e238546dc