@@ -772,9 +772,11 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
772772
773773 // Produce a diagnostic if we're not tentatively parsing; otherwise track
774774 // that our parse has failed.
775- auto Invalid = [&](llvm::function_ref<void ()> Action) {
775+ auto Result = [&](llvm::function_ref<void ()> Action,
776+ LambdaIntroducerTentativeParse State =
777+ LambdaIntroducerTentativeParse::Invalid) {
776778 if (Tentative) {
777- *Tentative = LambdaIntroducerTentativeParse::Invalid ;
779+ *Tentative = State ;
778780 return false ;
779781 }
780782 Action ();
@@ -824,7 +826,7 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
824826 break ;
825827 }
826828
827- return Invalid ([&] {
829+ return Result ([&] {
828830 Diag (Tok.getLocation (), diag::err_expected_comma_or_rsquare);
829831 });
830832 }
@@ -861,7 +863,7 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
861863 ConsumeToken ();
862864 Kind = LCK_StarThis;
863865 } else {
864- return Invalid ([&] {
866+ return Result ([&] {
865867 Diag (Tok.getLocation (), diag::err_expected_star_this_capture);
866868 });
867869 }
@@ -875,8 +877,9 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
875877 // or the start of a capture (in the "&" case) with the rest of the
876878 // capture missing. Both are an error but a misplaced capture-default
877879 // is more likely if we don't already have a capture default.
878- return Invalid (
879- [&] { Diag (Tok.getLocation (), diag::err_capture_default_first); });
880+ return Result (
881+ [&] { Diag (Tok.getLocation (), diag::err_capture_default_first); },
882+ LambdaIntroducerTentativeParse::Incomplete);
880883 } else {
881884 TryConsumeToken (tok::ellipsis, EllipsisLocs[0 ]);
882885
@@ -899,14 +902,13 @@ bool Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
899902 Id = Tok.getIdentifierInfo ();
900903 Loc = ConsumeToken ();
901904 } else if (Tok.is (tok::kw_this)) {
902- return Invalid ([&] {
905+ return Result ([&] {
903906 // FIXME: Suggest a fixit here.
904907 Diag (Tok.getLocation (), diag::err_this_captured_by_reference);
905908 });
906909 } else {
907- return Invalid ([&] {
908- Diag (Tok.getLocation (), diag::err_expected_capture);
909- });
910+ return Result (
911+ [&] { Diag (Tok.getLocation (), diag::err_expected_capture); });
910912 }
911913
912914 TryConsumeToken (tok::ellipsis, EllipsisLocs[2 ]);
0 commit comments