llvm/clang/test/SemaObjC/attr-swift_objc_members.m
Saleem Abdulrasool 916b434035 Sema: add support for __attribute__((__swift_objc_members__))
This adds the `__swift_objc_members__` attribute to the semantic
analysis.  It allows for annotating ObjC interfaces to provide Swift
semantics indicating that the types derived from this interface will be
back-bridged to Objective-C to allow interoperability with Objective-C
and Swift.

This is based on the work of the original changes in
8afaf3aad2

Differential Revision: https://reviews.llvm.org/D87395
Reviewed By: Aaron Ballman, Dmitri Gribenko
2020-09-14 15:24:41 +00:00

25 lines
696 B
Objective-C

// RUN: %clang_cc1 -verify -fsyntax-only %s
#if !__has_attribute(swift_objc_members)
#error cannot verify presence of swift_objc_members attribute
#endif
__attribute__((__swift_objc_members__))
__attribute__((__objc_root_class__))
@interface I
@end
__attribute__((swift_objc_members))
@protocol P
@end
// expected-error@-3 {{'swift_objc_members' attribute only applies to Objective-C interfaces}}
__attribute__((swift_objc_members))
extern void f(void);
// expected-error@-2 {{'swift_objc_members' attribute only applies to Objective-C interfaces}}
// expected-error@+1 {{'__swift_objc_members__' attribute takes no arguments}}
__attribute__((__swift_objc_members__("J")))
@interface J
@end