Interestingly enough, it *does* happen, but it's okay. There are only
three places where we call cp_parser_enclosed_template_argument_list
and can have '>>' changed to '>'. In all of the cases, we throw away
the entire template argument list, either because it was erroneous
(cp_parser_check_for_invalid_template_id and cp_parser_template_name
act this way) or because we're replacing it with a CPP_TEMPLATE_ID
(cp_parser_template_id does this). In either case, it's actually
important that the change from '>>' to '>' "stick", because that '>'
might still need to be parsed to close a new-style cast expression,
even in an error case:
static_cast<int<int>>(0)
After auditing these calls to
cp_parser_enclosed_template_argument_list, I'm certain that we're
doing the righ tthing by *not* trying to back out the change from '>>'
to '>', and that the patch is correct as written. I've added another
test case (see below) that tests some of the more interesting cases.