From patchwork Tue Mar 14 22:10:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 69852 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2008598wrd; Tue, 14 Mar 2023 15:11:08 -0700 (PDT) X-Google-Smtp-Source: AK7set/6GsQhU3gE+JL5PiLugoBCmERqGrHkIwK12kq4RnGjpY6wQpmz74U/Bhd0XfIAkmINvOs6 X-Received: by 2002:a17:906:71db:b0:927:de85:96a2 with SMTP id i27-20020a17090671db00b00927de8596a2mr4680713ejk.38.1678831868382; Tue, 14 Mar 2023 15:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678831868; cv=none; d=google.com; s=arc-20160816; b=ztW5SxBF8NYghs47M5SBRA3gcfHWFaT3ByEMHkmNfLcNK3QajEbZrwhRLkZ1kyD8JZ R0oMyIzbOQ6gbEvgCpYt9dFuPVuGnt0IfLP8F5PVA1WDn8E3lpaNMAzj4RdMTumaQxqp GUT+7X6cPlCmCB7De0KOdFIIt7hdMgVGM2IVp34yFTLro3znLJmRSv98SZeali5ogl9m BK14rYQnWnAs7oz9yLb3pMltJ2BIhODqOLy9amCSld8HZvWw0q6ZF5Bj81CVZWFyC60l +KbUyI/nV1nkf3W1dlMOS2z+xUEtPDt4Mz66ZWiFcThdKb7wIZwI5N+i/QCEXXO8bpR5 MaQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=nIsBeXhJQCiPN9YcWLlWExftbJs6w752wWkgus/9ONc=; b=O7K+WZ1aKH492Xr11HddbzDgyqoDS1mv56tJkk5v4vRbP1/CY62HLFWZcMjU3Kel6o qU0CFh7KeGgx+0T6LdiJKtzo2AqyQDaLmLiPcWik08qk9I5TOtAergAcN3GcFqEAIhD/ eJkn2EHAUkPvTKmFnELYpZhX3cPjlZYzbHx97bTFkbzKKP987x46HbRC7MAHU3vsGWYu PBlYsRI+tk6Rc8ca6qntb34B/4EMl0lKBfrAwjyMNZ2jt/i04W/E/v/msQ8c4hBKWMtX FIiMTery4IzzaZ92EVILisf3A/50hYzuFL3xHNgijEZgJh6WYGe/x560dacWVH8PgY2R Fd8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fvepWBee; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n10-20020a170906688a00b008f5db5a1501si3703248ejr.31.2023.03.14.15.11.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 15:11:08 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fvepWBee; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51047385842C for ; Tue, 14 Mar 2023 22:11:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51047385842C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678831867; bh=nIsBeXhJQCiPN9YcWLlWExftbJs6w752wWkgus/9ONc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fvepWBee/Ogjs0vDf9nUKwbBqQrPQtmbH4Uuks1dDc+PQRluZWZhwPYzCLqQVhabZ rrdNQoQP91DUbvAdpgeSUYyYa0fMmNYAhAbEOMxJFb1w8ZTJyIo19vt58W6QUFFdwi 11HMu7XoXfka32GVrtx3rX+SCCTKdNAOtGWd5GLU= 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 112943858D33 for ; Tue, 14 Mar 2023 22:10:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 112943858D33 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-498-rwSrj34HO2Si3YNGtKh-aQ-1; Tue, 14 Mar 2023 18:10:23 -0400 X-MC-Unique: rwSrj34HO2Si3YNGtKh-aQ-1 Received: by mail-qk1-f199.google.com with SMTP id az31-20020a05620a171f00b00745746178e2so4616966qkb.6 for ; Tue, 14 Mar 2023 15:10:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678831822; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nIsBeXhJQCiPN9YcWLlWExftbJs6w752wWkgus/9ONc=; b=niEh6X3htJs1jzKr1JE964ZHDx1/h85DvihJuDPwiMxauRZjQ+RSJu6d2z3LGn7yrd VVagRdRL/uT34YoRV5psXTxLm1KE3MarvuRcmRF5ci5CfWSbUSoO0+ymelHvwPH0okNh gAuo1MtvLm8h+F8ju6FyYu+9M7lIyPwDya/IF3KYqC1T9sODvy7UTs/CaGLGlw1kUcKm RcaDKl+PbTxP8Zphw8n0iaiK4n4ZQeOXkPVcoQ0fMOolB8jHuujeY03h9vDg0rWelkjV AzCYWhB65jLAnTds6UcqkJ0VxAsNTzhdgesiig5qcizknkhcz/bz1sCHs6s0Tq/yPG4C ypZQ== X-Gm-Message-State: AO0yUKViMULdgco0csQ/FsYUV3YpELrsPNEIZ/QlbSWIdcXjIMs5reTD X/nyCEwrtSb9MMfRTAzbbf/eBT7vYTlD/lbHWmRA5UNjXaIEi+kR96+eaeyFW834mVZH8KKU5jD z8K7rHS4kGIKuNuR/FZDsWLg7AWaJaqpZMdJspirl8Hjxmdz63HonDzKNYMS752Qmq5yFeJxCyg == X-Received: by 2002:ac8:7c56:0:b0:3c0:14ec:bfbf with SMTP id o22-20020ac87c56000000b003c014ecbfbfmr61051102qtv.25.1678831822710; Tue, 14 Mar 2023 15:10:22 -0700 (PDT) X-Received: by 2002:ac8:7c56:0:b0:3c0:14ec:bfbf with SMTP id o22-20020ac87c56000000b003c014ecbfbfmr61051051qtv.25.1678831822246; Tue, 14 Mar 2023 15:10:22 -0700 (PDT) Received: from jason.cygnus.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id a134-20020ae9e88c000000b007425dade624sm2579146qkg.41.2023.03.14.15.10.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 15:10:21 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: variable tmpl partial specialization [PR108468] Date: Tue, 14 Mar 2023 18:10:19 -0400 Message-Id: <20230314221019.463098-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.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_H2, 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: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760382805083229819?= X-GMAIL-MSGID: =?utf-8?q?1760382805083229819?= Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- Generally we expect TPARMS_PRIMARY_TEMPLATE to be set, but sometimes it isn't for partial instantiations. This ought to be improved, but it's trivial to work around it in this case. PR c++/108468 gcc/cp/ChangeLog: * pt.cc (unify_pack_expansion): Check that TPARMS_PRIMARY_TEMPLATE is non-null. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/var-templ78.C: New test. --- gcc/cp/pt.cc | 2 ++ gcc/testsuite/g++.dg/cpp1y/var-templ78.C | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/var-templ78.C base-commit: 2b204accd07a3185b58b1edc6e9b019472857a5d diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 65341c40f97..c53d8e279c6 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -24148,6 +24148,8 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms, arguments if it is not otherwise deduced. */ if (cxx_dialect >= cxx20 && TREE_VEC_LENGTH (new_args) < TREE_VEC_LENGTH (old_args) + /* FIXME This isn't set properly for partial instantiations. */ + && TPARMS_PRIMARY_TEMPLATE (tparms) && builtin_guide_p (TPARMS_PRIMARY_TEMPLATE (tparms))) TREE_VEC_LENGTH (old_args) = TREE_VEC_LENGTH (new_args); if (!comp_template_args (old_args, new_args, diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ78.C b/gcc/testsuite/g++.dg/cpp1y/var-templ78.C new file mode 100644 index 00000000000..48366c92775 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ78.C @@ -0,0 +1,12 @@ +// PR c++/108468 +// { dg-do compile { target c++14 } } + +template struct C { + template + static constexpr int x = 1; +}; + +template template +int C::x = 2; + +int y = C<0>::x;