1 // RUN: %clang_cc1 -verify %s -x objective-c
2 // RUN: %clang_cc1 -verify %s -x objective-c++
5 #define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
6 #define NS_ENUM(_type, _name) CF_ENUM(_type, _name)
8 #define NS_ERROR_ENUM(_type, _name, _domain) \
9 enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
11 typedef NS_ENUM(unsigned, MyEnum) {
16 typedef NS_ENUM(invalidType, MyInvalidEnum) {
17 // expected-error@-1{{unknown type name 'invalidType'}}
18 // expected-error@-2{{unknown type name 'invalidType'}}
26 extern NSString *const MyErrorDomain;
27 typedef NS_ERROR_ENUM(unsigned char, MyErrorEnum, MyErrorDomain) {
32 typedef NSString *const NsErrorDomain;
33 extern NsErrorDomain MyTypedefErrorDomain;
34 typedef NS_ERROR_ENUM(unsigned char, MyTypedefErrorEnum, MyTypedefErrorDomain) {
39 typedef const struct __CFString * CFStringRef;
41 extern CFStringRef const MyCFErrorDomain;
42 typedef NS_ERROR_ENUM(unsigned char, MyCFErrorEnum, MyCFErrorDomain) {
47 typedef CFStringRef CFErrorDomain;
48 extern CFErrorDomain const MyCFTypedefErrorDomain;
49 typedef NS_ERROR_ENUM(unsigned char, MyCFTypedefErrorEnum, MyCFTypedefErrorDomain) {
54 extern char *const WrongErrorDomainType;
55 enum __attribute__((ns_error_domain(WrongErrorDomainType))) MyWrongErrorDomainType { MyWrongErrorDomain };
56 // expected-error@-1{{domain argument 'WrongErrorDomainType' does not point to an NSString or CFString constant}}
58 struct __attribute__((ns_error_domain(MyErrorDomain))) MyStructWithErrorDomain {};
59 // expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
61 int __attribute__((ns_error_domain(MyErrorDomain))) NotTagDecl;
62 // expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
64 enum __attribute__((ns_error_domain())) NoArg { NoArgError };
65 // expected-error@-1{{'ns_error_domain' attribute takes one argument}}
67 enum __attribute__((ns_error_domain(MyErrorDomain, MyErrorDomain))) TwoArgs { TwoArgsError };
68 // expected-error@-1{{'ns_error_domain' attribute takes one argument}}
70 typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, InvalidDomain) {
71 // expected-error@-1{{use of undeclared identifier 'InvalidDomain'}}
76 typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, "domain-string");
77 // expected-error@-1{{domain argument does not refer to global constant}}
80 typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalidFunction, foo);
81 // expected-error@-1{{domain argument 'foo' does not refer to global constant}}