https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106310
--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:db6c4ba976a795480cbccc380e3a84eec1de8e68 commit r13-7712-gdb6c4ba976a795480cbccc380e3a84eec1de8e68 Author: Jason Merrill <ja...@redhat.com> Date: Wed Jul 26 10:39:34 2023 -0400 c++: member vs global template [PR106310] For backward compatibility we still want to allow patterns like this->A<T>::foo, but the template keyword in a qualified name is specifically to specify that a dependent name is a template, so don't look in the enclosing scope at all. Also fix handling of dependent bases: if member lookup in the current instantiation fails and we have dependent bases, the lookup is dependent. We were already handling that for the case where lookup in the enclosing scope also fails, but we also want it to affect that lookup itself. PR c++/106310 gcc/cp/ChangeLog: * parser.cc (cp_parser_template_name): Skip non-member lookup after the template keyword. (cp_parser_lookup_name): Pass down template_keyword_p. gcc/testsuite/ChangeLog: * g++.dg/template/template-keyword4.C: New test.