<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64438>64438</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang can't compile headers from the MacOSX14 SDK when targeting catalyst
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nico
</td>
</tr>
</table>
<pre>
This builds with Xcode 14's clang, but not with open-source clang:
```
% cat test.m
#import <UIKit/UIKit.h>
% path/to/clang++ -std=c++11 -target arm64-apple-ios16.6-macabi -isysroot sdk/xcode_links/MacOSX14.0.sdk -isystem sdk/xcode_links/MacOSX14.0.sdk/System/iOSSupport/usr/include -iframework sdk/xcode_links/MacOSX14.0.sdk/System/iOSSupport/System/Library/Frameworks ~/Desktop/foo.mm -o ~/Desktop/foo.a
…
sdk/xcode_links/MacOSX14.0.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderItem.h:127:32: error: 'NSFileProviderItemCapabilities' is unavailable: not available on macCatalyst
127 | typedef NS_OPTIONS(NSUInteger, NSFileProviderItemCapabilities) {
| ^
```
The diagnostic is correct! NSFileProviderItem.h does:
```
FILEPROVIDER_API_AVAILABILITY_V2_V3
typedef NS_OPTIONS(NSUInteger, NSFileProviderItemCapabilities) {
```
And NSFileProviderDefines.h does:
```
#define FILEPROVIDER_API_AVAILABILITY_V2_V3 API_AVAILABLE(ios(11.0), macos(11.0)) API_UNAVAILABLE(macCatalyst) API_UNAVAILABLE(watchos, tvos)
```
This expands to
```
__attribute__((availability(ios,introduced=11.0))) __attribute__((availability(macos,introduced=11.0))) __attribute__((availability(macCatalyst,unavailable))) __attribute__((availability(watchos,unavailable))) __attribute__((availability(tvos,unavailable)))
```
and it does mark NSFileProviderItemCapabilities as unavailable on macOS.
In the 13.3 SDK, CFAvailability.h did:
```
#define CF_OPTIONS(_type, _name) _type _name; enum __CF_OPTIONS_ATTRIBUTES : _type
```
But in the 14.0 SDK, it instead does:
```
+#define CF_OPTIONS(_type, _name) _type _name; enum __CF_OPTIONS_ATTRIBUTES : _name
```
That is, previously the enum values were in an unnamed enum with underlying type NSUInteger, but now they're in an unnamed enum with underlying type NSFileProviderItemCapabilities. NSFileProviderItemCapabilities is unavailable and now referenced, so clang warns.
Here's a reduced repro based on that:
```
% cat repro.mm
#define CF_OPTIONS(_type, _name) enum : _name
__attribute__((availability(macos,introduced=11.0)))
__attribute__((availability(macCatalyst,unavailable)))
typedef unsigned NSFileProviderItemCapabilities;
CF_OPTIONS(unsigned, NSFileProviderItemCapabilities) {
A = 0,
};
```
% out/gn/bin/clang -std=c++17 -target arm64-apple-ios16.6-macabi repro.mm -isysroot ~/Downloads/MacOSX14.sdk -c
repro.mm:7:22: error: 'NSFileProviderItemCapabilities' is unavailable: not available on macCatalyst
7 | CF_OPTIONS(unsigned, NSFileProviderItemCapabilities) {
| ^
repro.mm:5:18: note: 'NSFileProviderItemCapabilities' has been explicitly marked unavailable here
5 | typedef unsigned NSFileProviderItemCapabilities;
| ^
1 error generated.
```
Xcode 13.3's clang diags the same way on this repro. But Xcode 14's doesn't:
```
% /Users/thakis/Downloads/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -std=c++17 -target arm64-apple-ios16.6-macabi repro.mm -isysroot ~/Downloads/MacOSX14.sdk -c
# no diag
```
But if I remove the CF_OPTIONS macro and inline its contents, then xcode 14's clang also diags.
So it must have some "if avail diag is for unnamed enum where both the unavail type and the enum keyword are part of a macros, then don't diag" logic I guess?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8WFuP4joS_jXmpUSUOFwfeODS0UGnt3s09IzOPiEnLoiXxI5sB5qX_e0rO1x7WJrec_a0RjAx5aK-8ldVn2HGiLVEHJHuhHRnLVbbXOmRFJlqpYrvR2-5MJDWouAGdsLm8EemOELUIbRvICuYXBM6hbS2IJVtTFSFsm1UrTM8WMRjEs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