From: Jason Merrill Date: Tue, 14 Mar 2023 20:32:31 +0000 (-0400) Subject: c++: variable tmpl partial specialization [PR108468] X-Git-Tag: upstream/13.1.0~570 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e44a9932c11f028269f3aa7e3031e703d151b0b;p=platform%2Fupstream%2Fgcc.git 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.cc (unify_pack_expansion): Check that TPARMS_PRIMARY_TEMPLATE is non-null. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/var-templ78.C: New test. --- diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 65341c4..c53d8e2 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 0000000..48366c9 --- /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;