@@ -1537,15 +1537,17 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
1537
1537
// over to the alternate parsing path.
1538
1538
DeclAttrKind DK = DeclAttribute::getAttrKindFromString (Tok.getText ());
1539
1539
1540
- auto checkInvalidAttrName = [&](StringRef invalidName, StringRef correctName,
1541
- DeclAttrKind kind, Diag<StringRef, StringRef> diag) {
1540
+ auto checkInvalidAttrName = [&](StringRef invalidName,
1541
+ StringRef correctName,
1542
+ DeclAttrKind kind,
1543
+ Optional<Diag<StringRef, StringRef>> diag = None) {
1542
1544
if (DK == DAK_Count && Tok.getText () == invalidName) {
1543
- // We renamed @availability to @available, so if we see the former,
1544
- // treat it as the latter and emit a Fix-It.
1545
1545
DK = kind;
1546
-
1547
- diagnose (Tok, diag, invalidName, correctName)
1546
+
1547
+ if (diag) {
1548
+ diagnose (Tok, *diag, invalidName, correctName)
1548
1549
.fixItReplace (Tok.getLoc (), correctName);
1550
+ }
1549
1551
}
1550
1552
};
1551
1553
@@ -1556,14 +1558,17 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
1556
1558
// Check if attr is inlineable, and suggest inlinable instead
1557
1559
checkInvalidAttrName (" inlineable" , " inlinable" , DAK_Inlinable, diag::attr_name_close_match);
1558
1560
1559
- // In Swift 5 and above, these become hard errors. Otherwise, emit a
1560
- // warning for compatibility.
1561
- if (!Context.isSwiftVersionAtLeast (5 )) {
1561
+ // In Swift 5 and above, these become hard errors. In Swift 4.2, emit a
1562
+ // warning for compatibility. Otherwise, don't diagnose at all.
1563
+ if (Context.isSwiftVersionAtLeast (5 )) {
1564
+ checkInvalidAttrName (" _versioned" , " usableFromInline" , DAK_UsableFromInline, diag::attr_renamed);
1565
+ checkInvalidAttrName (" _inlineable" , " inlinable" , DAK_Inlinable, diag::attr_renamed);
1566
+ } else if (Context.isSwiftVersionAtLeast (4 , 2 )) {
1562
1567
checkInvalidAttrName (" _versioned" , " usableFromInline" , DAK_UsableFromInline, diag::attr_renamed_warning);
1563
1568
checkInvalidAttrName (" _inlineable" , " inlinable" , DAK_Inlinable, diag::attr_renamed_warning);
1564
1569
} else {
1565
- checkInvalidAttrName (" _versioned" , " usableFromInline" , DAK_UsableFromInline, diag::attr_renamed );
1566
- checkInvalidAttrName (" _inlineable" , " inlinable" , DAK_Inlinable, diag::attr_renamed );
1570
+ checkInvalidAttrName (" _versioned" , " usableFromInline" , DAK_UsableFromInline);
1571
+ checkInvalidAttrName (" _inlineable" , " inlinable" , DAK_Inlinable);
1567
1572
}
1568
1573
1569
1574
if (DK == DAK_Count && Tok.getText () == " warn_unused_result" ) {
0 commit comments