@@ -2798,6 +2798,8 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
27982798 // diagnostic this can be used for better error presentation.
27992799 SourceRange AttrRange;
28002800
2801+ ParserStatus Status;
2802+
28012803 switch (DK) {
28022804 case DAK_Count:
28032805 llvm_unreachable (" DAK_Count should not appear in parsing switch" );
@@ -3583,16 +3585,16 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
35833585 case DAK_StorageRestrictions: {
35843586 ParserResult<StorageRestrictionsAttr> Attr =
35853587 parseStorageRestrictionsAttribute (AtLoc, Loc);
3586- if (!Attr.isParseErrorOrHasCompletion ()) {
3588+ Status |= Attr;
3589+ if (Attr.isNonNull ()) {
35873590 Attributes.add (Attr.get ());
3588- } else {
3589- return Attr;
35903591 }
35913592 break ;
35923593 }
35933594
35943595 case DAK_Implements: {
35953596 ParserResult<ImplementsAttr> Attr = parseImplementsAttribute (AtLoc, Loc);
3597+ Status |= Attr;
35963598 if (Attr.isNonNull ()) {
35973599 Attributes.add (Attr.get ());
35983600 }
@@ -3601,6 +3603,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
36013603
36023604 case DAK_Differentiable: {
36033605 auto Attr = parseDifferentiableAttribute (AtLoc, Loc);
3606+ Status |= Attr;
36043607 if (Attr.isNonNull ())
36053608 Attributes.add (Attr.get ());
36063609 break ;
@@ -3612,6 +3615,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
36123615 diagnose (Loc, diag::attr_only_at_non_local_scope, ' @' + AttrName.str ());
36133616
36143617 auto Attr = parseDerivativeAttribute (AtLoc, Loc);
3618+ Status |= Attr;
36153619 if (Attr.isNonNull ())
36163620 Attributes.add (Attr.get ());
36173621 break ;
@@ -3623,6 +3627,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
36233627 diagnose (Loc, diag::attr_only_at_non_local_scope, ' @' + AttrName.str ());
36243628
36253629 auto Attr = parseTransposeAttribute (AtLoc, Loc);
3630+ Status |= Attr;
36263631 if (Attr.isNonNull ())
36273632 Attributes.add (Attr.get ());
36283633 break ;
@@ -3693,6 +3698,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
36933698 }
36943699 case DAK_Documentation: {
36953700 auto Attr = parseDocumentationAttribute (AtLoc, Loc);
3701+ Status |= Attr;
36963702 if (Attr.isNonNull ())
36973703 Attributes.add (Attr.get ());
36983704 else
@@ -3703,6 +3709,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
37033709 auto syntax = (AttrName == " freestanding" ? MacroSyntax::Freestanding
37043710 : MacroSyntax::Attached);
37053711 auto Attr = parseMacroRoleAttribute (syntax, AtLoc, Loc);
3712+ Status |= Attr;
37063713 if (Attr.isNonNull ())
37073714 Attributes.add (Attr.get ());
37083715 else
@@ -3861,7 +3868,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
38613868 if (AtLoc.isValid () && DeclAttribute::isDeclModifier (DK))
38623869 diagnose (AtLoc, diag::cskeyword_not_attribute, AttrName).fixItRemove (AtLoc);
38633870
3864- return makeParserSuccess () ;
3871+ return Status ;
38653872}
38663873
38673874bool Parser::parseVersionTuple (llvm::VersionTuple &Version,
0 commit comments