In this testcase, in C++17 mode after parsing the template-id fails, we try to treat the template-name as a class template deduction placeholder, producing an auto type, and then we try to take its TREE_TYPE when calling cp_parser_check_for_invalid_type_id, which doesn't work because it's a type, not a TYPE_DECL. Fixed by removing the TREE_TYPE and adjusting cp_parser_check_for_invalid_type_id to handle TYPE_DECL. Really we shouldn't be creating a deduction placeholder in the first place when the template name is followed by <, but that distinction shouldn't affect well-formed code since we try to parse a template-id first. I still want to improve our handling of parse errors in template-ids; we never actually diagnose the syntax error here because it's swallowed by tentative parsing, we just say "argument 1 is invalid". Tested x86_64-pc-linux-gnu, applying to trunk.