Issue |
142502
|
Summary |
LLVM/Clang does not process visionos availability correctly
|
Labels |
clang
|
Assignees |
|
Reporter |
stuartcarnie
|
The following snippet of Objective-C code, which declares the `typedef` as available on watchOS, and unavailable on iOS, macOS and tvOS platforms:
```objectivec
#import <Foundation/Foundation.h>
API_UNAVAILABLE(visionos) @interface Foo
@end
typedef void(^Bar)(Foo *foo) API_AVAILABLE(watchos(5.0)) API_UNAVAILABLE(ios,macos,tvos);
```
Given iOS is unavailable, it also includes derivatives, which means visionOS.
Compiling this snippet with Apple's clang compiler works as expected:
```
echo "#import <Foundation/Foundation.h>\nAPI_UNAVAILABLE(visionos) @interface Foo\n@end\n typedef void(^Bar)(Foo *foo) API_AVAILABLE(watchos(5.0)) API_UNAVAILABLE(ios,macos,tvos);" | xcrun -sdk xros clang -mtargetos=xros2.5 -O2 -x objective-c -c -o test.o -
```
However, compiling with clang from here fails:
```
echo -e "#import <Foundation/Foundation.h>\nAPI_UNAVAILABLE(visionos) @interface Foo\n@end\ntypedef void(^Bar)(Foo *foo) API_AVAILABLE(watchos(5.0)) API_UNAVAILABLE(ios,macos,tvos);" | arm-apple-darwin11-clang -isysroot /root/SDKs/XROS2.5.sdk/ -mtargetos=xros2.5 -O2 -x objective-c -c -o test.o -
```
**Output**:
```
<stdin>:4:20: error: 'Foo' is unavailable: not available on visionOS
4 | typedef void(^Bar)(Foo *foo) API_AVAILABLE(watchos(5.0)) API_UNAVAILABLE(ios,macos,tvos);
| ^ <stdin>:2:38: note: 'Foo' has been explicitly marked unavailable here 2 | API_UNAVAILABLE(visionos) @interface Foo
| ^
1 error generated.
```
If I explicitly add `visionos` to the `typedef` declaration, it passes.
Unfortunately, this problem occurs when compiling Apple's SDKs, such as `CoreMotion` with llvm / clang, that has declarations such as:
```objectivec
/*!
* @typedef CMDyskineticSymptomResultHandler
* @brief Completion handler for CMDyskineticSymptomResult values.
*/
typedef void(^CMDyskineticSymptomResultHandler)(NSArray<CMDyskineticSymptomResult *> * _Nonnull dyskineticSymptomResult, NSError * _Nullable error) API_AVAILABLE(watchos(5.0)) API_UNAVAILABLE(ios, macos, tvos);
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs