@@ -1618,7 +1618,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
16181618 else if (Tok.getText() == "releasenone")
16191619 kind = EffectsKind::ReleaseNone;
16201620 else {
1621- diagnose(Loc, diag::effects_attribute_unknown_option ,
1621+ diagnose(Loc, diag::attr_unknown_option ,
16221622 Tok.getText(), AttrName);
16231623 return false;
16241624 }
@@ -1644,8 +1644,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
16441644 }
16451645
16461646 if (Tok.isNot(tok::identifier)) {
1647- diagnose(Loc, diag::optimization_attribute_expect_option, AttrName,
1648- "none");
1647+ diagnose(Loc, diag::attr_expected_option_such_as, AttrName, "none");
16491648 return false;
16501649 }
16511650
@@ -1655,8 +1654,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
16551654 else if (Tok.getText() == "__always")
16561655 kind = InlineKind::Always;
16571656 else {
1658- diagnose(Loc, diag::optimization_attribute_unknown_option,
1659- Tok.getText(), AttrName);
1657+ diagnose(Loc, diag::attr_unknown_option, Tok.getText(), AttrName);
16601658 return false;
16611659 }
16621660 consumeToken(tok::identifier);
@@ -1674,6 +1672,45 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
16741672 break;
16751673 }
16761674
1675+ case DAK_ActorIndependent: {
1676+ // if no option is provided, then it's the 'safe' version.
1677+ if (!consumeIf(tok::l_paren)) {
1678+ if (!DiscardAttribute) {
1679+ AttrRange = SourceRange(Loc, Tok.getRange().getStart());
1680+ Attributes.add(new (Context) ActorIndependentAttr(AtLoc, AttrRange,
1681+ ActorIndependentKind::Safe));
1682+ }
1683+ break;
1684+ }
1685+
1686+ // otherwise, make sure it looks like an identifier.
1687+ if (Tok.isNot(tok::identifier)) {
1688+ diagnose(Loc, diag::attr_expected_option_such_as, AttrName, "unsafe");
1689+ return false;
1690+ }
1691+
1692+ // make sure the identifier is 'unsafe'
1693+ if (Tok.getText() != "unsafe") {
1694+ diagnose(Loc, diag::attr_unknown_option, Tok.getText(), AttrName);
1695+ return false;
1696+ }
1697+
1698+ consumeToken(tok::identifier);
1699+ AttrRange = SourceRange(Loc, Tok.getRange().getStart());
1700+
1701+ if (!consumeIf(tok::r_paren)) {
1702+ diagnose(Loc, diag::attr_expected_rparen, AttrName,
1703+ DeclAttribute::isDeclModifier(DK));
1704+ return false;
1705+ }
1706+
1707+ if (!DiscardAttribute)
1708+ Attributes.add(new (Context) ActorIndependentAttr(AtLoc, AttrRange,
1709+ ActorIndependentKind::Unsafe));
1710+
1711+ break;
1712+ }
1713+
16771714 case DAK_Optimize: {
16781715 if (!consumeIf(tok::l_paren)) {
16791716 diagnose(Loc, diag::attr_expected_lparen, AttrName,
@@ -1682,8 +1719,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
16821719 }
16831720
16841721 if (Tok.isNot(tok::identifier)) {
1685- diagnose(Loc, diag::optimization_attribute_expect_option, AttrName,
1686- "speed");
1722+ diagnose(Loc, diag::attr_expected_option_such_as, AttrName, "speed");
16871723 return false;
16881724 }
16891725
@@ -1695,8 +1731,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
16951731 else if (Tok.getText() == "size")
16961732 optMode = OptimizationMode::ForSize;
16971733 else {
1698- diagnose(Loc, diag::optimization_attribute_unknown_option,
1699- Tok.getText(), AttrName);
1734+ diagnose(Loc, diag::attr_unknown_option, Tok.getText(), AttrName);
17001735 return false;
17011736 }
17021737 consumeToken(tok::identifier);
0 commit comments