From 66c74bb70f54bf7ebdb70a4286d756799eab21c0 Mon Sep 17 00:00:00 2001 From: Becca Royal-Gordon Date: Tue, 31 Jan 2023 16:16:16 -0800 Subject: [PATCH 1/4] [NFC] Fix change in SWIFT_CLASS_NAMED macro apple/swift#59072 accidentally changed the SWIFT_CLASS_NAMED macro to use `__attribute` when it previously used `__attribute__` (note the trailing underscores). While both keywords have the same semantics in clang, they are technically different tokens, so clang refuses to merge macro definitions that use one instead of the other; instead it would diagnose an ambiguity when a generated header from a new compiler imported a generated header from an old compiler. Change back to the old token to avoid this problem. Fixes rdar://104252758. --- include/swift/PrintAsClang/ClangMacros.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/swift/PrintAsClang/ClangMacros.def b/include/swift/PrintAsClang/ClangMacros.def index 233b46ca10fbb..2d9639d2087c3 100644 --- a/include/swift/PrintAsClang/ClangMacros.def +++ b/include/swift/PrintAsClang/ClangMacros.def @@ -133,7 +133,7 @@ CLANG_MACRO_BODY("SWIFT_CLASS", \ "SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) " \ "SWIFT_CLASS_EXTRA\n" \ "# define SWIFT_CLASS_NAMED(SWIFT_NAME) " \ - "__attribute((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) " \ + "__attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) " \ "SWIFT_CLASS_EXTRA\n" \ "# else\n" \ "# define SWIFT_CLASS(SWIFT_NAME) " \ From 5e143944f4f9b3579e1d6caae029a6f5451ae98a Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Fri, 24 Feb 2023 16:30:31 -0700 Subject: [PATCH 2/4] fix bad expansion of SWIFT_ENUM fixes 63837 --- include/swift/PrintAsClang/ClangMacros.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/swift/PrintAsClang/ClangMacros.def b/include/swift/PrintAsClang/ClangMacros.def index 2d9639d2087c3..ce6025fcfec72 100644 --- a/include/swift/PrintAsClang/ClangMacros.def +++ b/include/swift/PrintAsClang/ClangMacros.def @@ -175,7 +175,7 @@ CLANG_MACRO_CONDITIONAL("SWIFT_ENUM_ATTR", "(_extensibility)", \ CLANG_MACRO_BODY("SWIFT_ENUM", \ "# define SWIFT_ENUM(_type, _name, _extensibility) " \ "enum _name : _type _name; " \ - "enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name: _type\n" \ + "enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type\n" \ "# if __has_feature(generalized_swift_name)\n" \ "# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) " \ "enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); " \ From 6fe0f4e6bd9b451447e82b00b89d00c11badb99e Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Tue, 28 Feb 2023 14:25:35 -0700 Subject: [PATCH 3/4] fix typo in SWIFT_DEPRECATED_OBJC rdar://106046585 --- include/swift/PrintAsClang/ClangMacros.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/swift/PrintAsClang/ClangMacros.def b/include/swift/PrintAsClang/ClangMacros.def index ce6025fcfec72..0d3144c5d32b7 100644 --- a/include/swift/PrintAsClang/ClangMacros.def +++ b/include/swift/PrintAsClang/ClangMacros.def @@ -197,7 +197,7 @@ CLANG_MACRO("SWIFT_DEPRECATED", , "__attribute__((deprecated))") CLANG_MACRO("SWIFT_DEPRECATED_MSG", "(...)", "__attribute__((deprecated(__VA_ARGS__)))") CLANG_MACRO_ALTERNATIVE("SWIFT_DEPRECATED_OBJC", "(Msg)", \ - "__has_feature(attribute_diagnost_if_objc)", \ + "__has_feature(attribute_diagnose_if_objc)", \ "__attribute__((diagnose_if(1, Msg, \"warning\")))", \ "SWIFT_DEPRECATED_MSG(Msg)") From b2254bd5c0b7a906b0af4ff7cedb4d0013d0ae85 Mon Sep 17 00:00:00 2001 From: Victoria Mitchell Date: Wed, 1 Mar 2023 08:50:48 -0700 Subject: [PATCH 4/4] backport compatibility-macro fixes to 5.8 rdar://106086816