Index: lib/Parse/ParseTemplate.cpp =================================================================== --- lib/Parse/ParseTemplate.cpp +++ lib/Parse/ParseTemplate.cpp @@ -855,8 +855,12 @@ RemainingToken == tok::greater && PP.IsPreviousCachedToken(PrevTok)) { PrevTok.setKind(RemainingToken); PrevTok.setLength(1); - Token NewToks[] = {PrevTok, Tok}; - PP.ReplacePreviousCachedToken(NewToks); + // Break tok::greatergreater into two tok::greater but only add the second + // one in case the client asks to consume the last token. + if (ConsumeLastToken) + PP.ReplacePreviousCachedToken({PrevTok, Tok}); + else + PP.ReplacePreviousCachedToken({PrevTok}); } if (!ConsumeLastToken) { Index: test/Parser/objcxx11-protocol-in-template.mm =================================================================== --- test/Parser/objcxx11-protocol-in-template.mm +++ test/Parser/objcxx11-protocol-in-template.mm @@ -16,3 +16,11 @@ typedef int some_t; id FA(NSArray> *h, some_t group); + +template void F(Functor functor) {} + +void z() { + id

x = 0; + (void)x; + F( [ x = vector>{} ] {} ); +}