Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,11 @@ SIMPLE_DECL_ATTR(NSKeyedArchiverEncodeNonGenericSubclassesOnly,
OnClass | NotSerialized | LongAttribute,
/*Not serialized */ 70)

// HACK: Attribute needed to preserve source compatibility by downgrading errors
// due to an SDK change in Dispatch
SIMPLE_DECL_ATTR(_downgrade_exhaustivity_check, DowngradeExhaustivityCheck,
OnEnumElement | LongAttribute | UserInaccessible, 71)

#undef TYPE_ATTR
#undef DECL_ATTR_ALIAS
#undef SIMPLE_DECL_ATTR
Expand Down
4 changes: 4 additions & 0 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -3701,6 +3701,10 @@ NOTE(missing_particular_case,none,
WARNING(redundant_particular_case,none,
"case is already handled by previous patterns; consider removing it",())

// HACK: Downgrades the above to warnings if any of the cases is marked
// @_downgrade_exhaustivity_check.
WARNING(non_exhaustive_switch_warn_swift3,none, "switch must be exhaustive", ())

#ifndef DIAG_NO_UNDEF
# if defined(DIAG)
# undef DIAG
Expand Down
2 changes: 2 additions & 0 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,8 @@ namespace {

void visitEnumElementDecl(EnumElementDecl *EED) {
printCommon(EED, "enum_element_decl");
if (EED->getAttrs().hasAttribute<DowngradeExhaustivityCheckAttr>())
OS << "@_downgrade_exhaustivity_check";
PrintWithColorRAII(OS, ParenthesisColor) << ')';
}

Expand Down
4 changes: 4 additions & 0 deletions lib/AST/Attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
Printer.printAttrName("@_staticInitializeObjCMetadata");
break;

case DAK_DowngradeExhaustivityCheck:
Printer.printAttrName("@_downgrade_exhaustivity_check");
break;

case DAK_Count:
llvm_unreachable("exceed declaration attribute kinds");

Expand Down
2 changes: 2 additions & 0 deletions lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class AttributeEarlyChecker : public AttributeVisitor<AttributeEarlyChecker> {
IGNORED_ATTR(NSKeyedArchiverClassName)
IGNORED_ATTR(StaticInitializeObjCMetadata)
IGNORED_ATTR(NSKeyedArchiverEncodeNonGenericSubclassesOnly)
IGNORED_ATTR(DowngradeExhaustivityCheck)
#undef IGNORED_ATTR

// @noreturn has been replaced with a 'Never' return type.
Expand Down Expand Up @@ -784,6 +785,7 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
IGNORED_ATTR(ObjCMembers)
IGNORED_ATTR(StaticInitializeObjCMetadata)
IGNORED_ATTR(NSKeyedArchiverEncodeNonGenericSubclassesOnly)
IGNORED_ATTR(DowngradeExhaustivityCheck)
#undef IGNORED_ATTR

void visitAvailableAttr(AvailableAttr *attr);
Expand Down
1 change: 1 addition & 0 deletions lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6103,6 +6103,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
UNINTERESTING_ATTR(NSKeyedArchiverClassName)
UNINTERESTING_ATTR(StaticInitializeObjCMetadata)
UNINTERESTING_ATTR(NSKeyedArchiverEncodeNonGenericSubclassesOnly)
UNINTERESTING_ATTR(DowngradeExhaustivityCheck)
#undef UNINTERESTING_ATTR

void visitAvailableAttr(AvailableAttr *attr) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5915,7 +5915,7 @@ static bool hasGenericAncestry(ClassDecl *classDecl) {
/// Infer the attribute tostatic-initialize the Objective-C metadata for the
/// given class, if needed.
static void inferStaticInitializeObjCMetadata(ClassDecl *classDecl,
bool requiresNSCodingAttr) {
bool requiresNSCodingAttr) {
// If we already have the attribute, there's nothing to do.
if (classDecl->getAttrs().hasAttribute<StaticInitializeObjCMetadataAttr>())
return;
Expand Down
Loading