@@ -1466,15 +1466,17 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
1466
1466
// over to the alternate parsing path.
1467
1467
DeclAttrKind DK = DeclAttribute::getAttrKindFromString (Tok.getText ());
1468
1468
1469
- auto checkInvalidAttrName = [&](StringRef invalidName, StringRef correctName,
1470
- DeclAttrKind kind, Diag<StringRef, StringRef> diag) {
1469
+ auto checkInvalidAttrName = [&](StringRef invalidName,
1470
+ StringRef correctName,
1471
+ DeclAttrKind kind,
1472
+ Optional<Diag<StringRef, StringRef>> diag = None) {
1471
1473
if (DK == DAK_Count && Tok.getText () == invalidName) {
1472
- // We renamed @availability to @available, so if we see the former,
1473
- // treat it as the latter and emit a Fix-It.
1474
1474
DK = kind;
1475
-
1476
- diagnose (Tok, diag, invalidName, correctName)
1475
+
1476
+ if (diag) {
1477
+ diagnose (Tok, *diag, invalidName, correctName)
1477
1478
.fixItReplace (Tok.getLoc (), correctName);
1479
+ }
1478
1480
}
1479
1481
};
1480
1482
@@ -1485,14 +1487,17 @@ bool Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc) {
1485
1487
// Check if attr is inlineable, and suggest inlinable instead
1486
1488
checkInvalidAttrName (" inlineable" , " inlinable" , DAK_Inlinable, diag::attr_name_close_match);
1487
1489
1488
- // In Swift 5 and above, these become hard errors. Otherwise, emit a
1489
- // warning for compatibility.
1490
- if (!Context.isSwiftVersionAtLeast (5 )) {
1490
+ // In Swift 5 and above, these become hard errors. In Swift 4.2, emit a
1491
+ // warning for compatibility. Otherwise, don't diagnose at all.
1492
+ if (Context.isSwiftVersionAtLeast (5 )) {
1493
+ checkInvalidAttrName (" _versioned" , " usableFromInline" , DAK_UsableFromInline, diag::attr_renamed);
1494
+ checkInvalidAttrName (" _inlineable" , " inlinable" , DAK_Inlinable, diag::attr_renamed);
1495
+ } else if (Context.isSwiftVersionAtLeast (4 , 2 )) {
1491
1496
checkInvalidAttrName (" _versioned" , " usableFromInline" , DAK_UsableFromInline, diag::attr_renamed_warning);
1492
1497
checkInvalidAttrName (" _inlineable" , " inlinable" , DAK_Inlinable, diag::attr_renamed_warning);
1493
1498
} else {
1494
- checkInvalidAttrName (" _versioned" , " usableFromInline" , DAK_UsableFromInline, diag::attr_renamed );
1495
- checkInvalidAttrName (" _inlineable" , " inlinable" , DAK_Inlinable, diag::attr_renamed );
1499
+ checkInvalidAttrName (" _versioned" , " usableFromInline" , DAK_UsableFromInline);
1500
+ checkInvalidAttrName (" _inlineable" , " inlinable" , DAK_Inlinable);
1496
1501
}
1497
1502
1498
1503
if (DK == DAK_Count && Tok.getText () == " warn_unused_result" ) {
0 commit comments