https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104608
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:4602a494e94835f693a9230adb69ce92249ebf15 commit r12-7601-g4602a494e94835f693a9230adb69ce92249ebf15 Author: Marek Polacek <pola...@redhat.com> Date: Tue Feb 22 15:03:34 2022 -0500 c++: ->template and implicit typedef [PR104608] Here we have a forward declaration of Parameter for which we create an implicit typedef, which is a TYPE_DECL. Then, when looking it up at template definition time, cp_parser_template_id gets (since r12-6754) this TYPE_DECL which it can't handle. This patch defers lookup for TYPE_DECLs that cp_parser_template_id can't handle, a la r12-6879. PR c++/104608 gcc/cp/ChangeLog: * parser.cc (cp_parser_template_name): Repeat lookup of TYPE_DECLs. gcc/testsuite/ChangeLog: * g++.dg/parse/template-keyword3.C: New test. * g++.dg/parse/template-keyword4.C: New test.