@@ -2798,6 +2798,8 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
2798
2798
// diagnostic this can be used for better error presentation.
2799
2799
SourceRange AttrRange;
2800
2800
2801
+ ParserStatus Status;
2802
+
2801
2803
switch (DK) {
2802
2804
case DAK_Count:
2803
2805
llvm_unreachable (" DAK_Count should not appear in parsing switch" );
@@ -3583,16 +3585,16 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
3583
3585
case DAK_StorageRestrictions: {
3584
3586
ParserResult<StorageRestrictionsAttr> Attr =
3585
3587
parseStorageRestrictionsAttribute (AtLoc, Loc);
3586
- if (!Attr.isParseErrorOrHasCompletion ()) {
3588
+ Status |= Attr;
3589
+ if (Attr.isNonNull ()) {
3587
3590
Attributes.add (Attr.get ());
3588
- } else {
3589
- return Attr;
3590
3591
}
3591
3592
break ;
3592
3593
}
3593
3594
3594
3595
case DAK_Implements: {
3595
3596
ParserResult<ImplementsAttr> Attr = parseImplementsAttribute (AtLoc, Loc);
3597
+ Status |= Attr;
3596
3598
if (Attr.isNonNull ()) {
3597
3599
Attributes.add (Attr.get ());
3598
3600
}
@@ -3601,6 +3603,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
3601
3603
3602
3604
case DAK_Differentiable: {
3603
3605
auto Attr = parseDifferentiableAttribute (AtLoc, Loc);
3606
+ Status |= Attr;
3604
3607
if (Attr.isNonNull ())
3605
3608
Attributes.add (Attr.get ());
3606
3609
break ;
@@ -3612,6 +3615,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
3612
3615
diagnose (Loc, diag::attr_only_at_non_local_scope, ' @' + AttrName.str ());
3613
3616
3614
3617
auto Attr = parseDerivativeAttribute (AtLoc, Loc);
3618
+ Status |= Attr;
3615
3619
if (Attr.isNonNull ())
3616
3620
Attributes.add (Attr.get ());
3617
3621
break ;
@@ -3623,6 +3627,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
3623
3627
diagnose (Loc, diag::attr_only_at_non_local_scope, ' @' + AttrName.str ());
3624
3628
3625
3629
auto Attr = parseTransposeAttribute (AtLoc, Loc);
3630
+ Status |= Attr;
3626
3631
if (Attr.isNonNull ())
3627
3632
Attributes.add (Attr.get ());
3628
3633
break ;
@@ -3693,6 +3698,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
3693
3698
}
3694
3699
case DAK_Documentation: {
3695
3700
auto Attr = parseDocumentationAttribute (AtLoc, Loc);
3701
+ Status |= Attr;
3696
3702
if (Attr.isNonNull ())
3697
3703
Attributes.add (Attr.get ());
3698
3704
else
@@ -3703,6 +3709,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
3703
3709
auto syntax = (AttrName == " freestanding" ? MacroSyntax::Freestanding
3704
3710
: MacroSyntax::Attached);
3705
3711
auto Attr = parseMacroRoleAttribute (syntax, AtLoc, Loc);
3712
+ Status |= Attr;
3706
3713
if (Attr.isNonNull ())
3707
3714
Attributes.add (Attr.get ());
3708
3715
else
@@ -3861,7 +3868,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
3861
3868
if (AtLoc.isValid () && DeclAttribute::isDeclModifier (DK))
3862
3869
diagnose (AtLoc, diag::cskeyword_not_attribute, AttrName).fixItRemove (AtLoc);
3863
3870
3864
- return makeParserSuccess () ;
3871
+ return Status ;
3865
3872
}
3866
3873
3867
3874
bool Parser::parseVersionTuple (llvm::VersionTuple &Version,
0 commit comments