public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10640] c++: variable tmpl partial specialization [PR108468]
@ 2023-04-22  0:22 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2023-04-22  0:22 UTC (permalink / raw)
  To: gcc-cvs

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()>;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-22  0:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-22  0:22 [gcc r11-10640] c++: variable tmpl partial specialization [PR108468] Jason Merrill

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).