public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-10640] c++: variable tmpl partial specialization [PR108468]
Date: Sat, 22 Apr 2023 00:22:36 +0000 (GMT)	[thread overview]
Message-ID: <20230422002236.7C27E3858D20@sourceware.org> (raw)

https://gcc.gnu.org/g:469881efc4ad365dce3db26dab7d33f95d36f92f

commit r11-10640-g469881efc4ad365dce3db26dab7d33f95d36f92f
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 14 16:32:31 2023 -0400

    c++: variable tmpl partial specialization [PR108468]
    
    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.c (unify_pack_expansion): Check that TPARMS_PRIMARY_TEMPLATE
            is non-null.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp1y/var-templ78.C: New test.

Diff:
---
 gcc/cp/pt.c                              |  2 ++
 gcc/testsuite/g++.dg/cpp1y/var-templ78.C | 12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 588c46504b4..02a74bb3f49 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -23451,6 +23451,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<int> struct C {
+  template<class, class>
+  static constexpr int x = 1;
+};
+
+template<int I> template<class... A>
+int C<I>::x<void(A...), void(A...)> = 2;
+
+int y = C<0>::x<void(int), void()>;

                 reply	other threads:[~2023-04-22  0:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230422002236.7C27E3858D20@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).