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.129.124]) by sourceware.org (Postfix) with ESMTPS id 9144F3858D20 for ; Wed, 13 Sep 2023 17:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9144F3858D20 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=1694627602; 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=ocH7f7gE2Ix6s7k+ZmitjItwaw0+kV4SiPXWDKY+nZc=; b=a/GLM0bCYsm2vEBMGcMvCO1q1pBK1q9cjkvbSTKbiON5hACS5oOmJsdgJQO4HYhJ2c4Rpd EKTz/9dCls05MC1svtwlsL51FMTr3XPFL2seSL2ZuncAwpYtNcYCTZ8YzyDyBaOLfhLFLo 0dQ/+DN3U3plhKhagZChVwBj3QvnaUc= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-307-QxQ5DO38ODWQcAbI-zAmPA-1; Wed, 13 Sep 2023 13:53:20 -0400 X-MC-Unique: QxQ5DO38ODWQcAbI-zAmPA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-64a0166deb5so1132106d6.3 for ; Wed, 13 Sep 2023 10:53:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694627599; x=1695232399; 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=ocH7f7gE2Ix6s7k+ZmitjItwaw0+kV4SiPXWDKY+nZc=; b=iDqWQ1k9Bq9FFaBevmWITnyV3E8U4ZP9uK0jBMQif7n1l5yaN/4rELbLx7H6/oo6Qd 6P11JMcpuX5z4Oyzg1bB2O7qZ+jS93/JpjLnxbYErmDOjsGl7uUZAJM6TEBNZ9jI8Qqg zjZJBYSw2cKvWG46naBmp9g5n7XsWDamFyghpqfa9IlRb9agIdhpiRGnUrsnaFVYwsSU UGfO5qOGq/EU6P/c9SYNuzHhznydagWDxaom6TOiuIHnxolulUtwWxibn/ffoAmoVhQN oyF5h36WG1vf05cOFWcb3UGS+qLSOdKnvUa+ZX4fI9JVwDOuejK7w5vPvH4XTBTac2gY aMKw== X-Gm-Message-State: AOJu0YxPaz1aTOaLKr+rq10EkbHEYr0nyHtTx2RIKew/yqx5DaGTx4Zk I//Uhff9vw0ETrajeVwlhglzWEXXuASyPcQnhhmSCEWeJ0XGo2fbth6vMbISZk9MDFZwo5bxTcM qmVR0x6g5xxNW5sBjiYmWeYXljGrZ18qs6WSDTblxaWJnpX+tiBtuj3SBR7op3I+IGV9V/YgEk1 0= X-Received: by 2002:a0c:e0ce:0:b0:651:8efe:2a82 with SMTP id x14-20020a0ce0ce000000b006518efe2a82mr301971qvk.20.1694627599196; Wed, 13 Sep 2023 10:53:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFV/MDYiyzh1wOZbWk5ohVmW/KX+wb6q+FrBX1EKLC80GF8eaVoXv/IU2OX3qLGOLDg6fnpCA== X-Received: by 2002:a0c:e0ce:0:b0:651:8efe:2a82 with SMTP id x14-20020a0ce0ce000000b006518efe2a82mr301951qvk.20.1694627598726; Wed, 13 Sep 2023 10:53:18 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id l4-20020a0ce084000000b0064713c8fab7sm4577371qvk.59.2023.09.13.10.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 10:53:18 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: unifying identical tmpls from current inst [PR108347] Date: Wed, 13 Sep 2023 13:53:16 -0400 Message-ID: <20230913175316.4083902-1-ppalka@redhat.com> X-Mailer: git-send-email 2.42.0.158.g94e83dcf5b 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.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 List-Id: Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? -- >8 -- Here more_specialized_partial_spec considers the two partial specializations to be unordered ultimately because unify for identical parm=arg=A::C returns failure due to C being dependent. This patch fixes this by relaxing unify's early-exit identity test to also accept dependent decls; we can't deduce anything further from them anyway. In passing this patch removes the CONST_DECL case of unify: we should never see the CONST_DECL version of a template parameter here, and for other CONST_DECLs (such as enumerators) it seems we can rely on them already having been folded to their DECL_INITIAL. PR c++/108347 gcc/cp/ChangeLog: * pt.cc (unify): Return unify_success for identical dependent DECL_P 'arg' and 'parm'. : Remove handling. gcc/testsuite/ChangeLog: * g++.dg/template/ttp41.C: New test. --- gcc/cp/pt.cc | 10 ++-------- gcc/testsuite/g++.dg/template/ttp41.C | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/ttp41.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 838179d5fe3..c311a6b88f5 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -24568,7 +24568,8 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, even if ARG == PARM, since we won't record unifications for the template parameters. We might need them if we're trying to figure out which of two things is more specialized. */ - if (arg == parm && !uses_template_parms (parm)) + if (arg == parm + && (DECL_P (parm) || !uses_template_parms (parm))) return unify_success (explain_p); /* Handle init lists early, so the rest of the function can assume @@ -25286,13 +25287,6 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, return unify (tparms, targs, TREE_TYPE (parm), TREE_TYPE (arg), strict, explain_p); - case CONST_DECL: - if (DECL_TEMPLATE_PARM_P (parm)) - return unify (tparms, targs, DECL_INITIAL (parm), arg, strict, explain_p); - if (arg != scalar_constant_value (parm)) - return unify_template_argument_mismatch (explain_p, parm, arg); - return unify_success (explain_p); - case FIELD_DECL: case TEMPLATE_DECL: /* Matched cases are handled by the ARG == PARM test above. */ diff --git a/gcc/testsuite/g++.dg/template/ttp41.C b/gcc/testsuite/g++.dg/template/ttp41.C new file mode 100644 index 00000000000..c81e5dd2405 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ttp41.C @@ -0,0 +1,17 @@ +// PR c++/108347 + +template +struct A { + template struct C { }; + + template class TT, class U> + struct B; + + template + struct B; + + template + struct B { }; +}; + +A::B::C, const int*> b; -- 2.42.0.158.g94e83dcf5b