https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71954
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:ca2676654736e6b0bd1ba88edf5694df43718cd9 commit r14-3160-gca2676654736e6b0bd1ba88edf5694df43718cd9 Author: Patrick Palka <ppa...@redhat.com> Date: Fri Aug 11 13:25:58 2023 -0400 c++: recognize in-class var tmpl partial spec [PR71954] This makes us recognize member variable template partial specializations defined directly inside the class body. It seems we mainly just need to call check_explicit_specialization when we see a static TEMPLATE_ID_EXPR data member, which sets SET_DECL_TEMPLATE_SPECIALIZATION for us and which we otherwise don't call (for the out-of-class case we call it from grokvardecl). We also need to make finish_member_template_decl return NULL_TREE for such partial specializations, matching its behavior for class template partial specializations, so that later we don't try to register it as a separate member declaration. PR c++/71954 gcc/cp/ChangeLog: * decl.cc (grokdeclarator): Pass 'dname' instead of 'unqualified_id' as the name when building the VAR_DECL for a static data member. Call check_explicit_specialization for a TEMPLATE_ID_EXPR such member. * pt.cc (finish_member_template_decl): Return NULL_TREE instead of 'decl' when DECL_TEMPLATE_SPECIALIZATION is not set. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/var-templ84.C: New test. * g++.dg/cpp1y/var-templ84a.C: New test.