| 1 |
// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s |
| 2 |
|
| 3 |
@class NSError; |
| 4 |
|
| 5 |
#if __SIZEOF_POINTER__ == 4 |
| 6 |
typedef unsigned char BOOL; |
| 7 |
#else |
| 8 |
typedef _Bool BOOL; |
| 9 |
#endif |
| 10 |
|
| 11 |
typedef struct __attribute__((__objc_bridge__(NSError))) __CFError *CFErrorRef; |
| 12 |
|
| 13 |
extern int f0(void) __attribute__((__swift_error__)); |
| 14 |
// expected-error@-1 {{'__swift_error__' attribute takes one argument}} |
| 15 |
extern int f1(void) __attribute__((__swift_error__(invalid))); |
| 16 |
// expected-warning@-1 {{'__swift_error__' attribute argument not supported: 'invalid'}} |
| 17 |
extern int f2(void) __attribute__((__swift_error__(none,zero_result))); |
| 18 |
// expected-error@-1 {{use of undeclared identifier 'zero_result'}} |
| 19 |
|
| 20 |
@interface Erroneous |
| 21 |
- (BOOL)m0:(NSError **)error __attribute__((__swift_error__(none))); |
| 22 |
- (BOOL)m1:(NSError **)error __attribute__((__swift_error__(nonnull_error))); |
| 23 |
- (BOOL)m2:(NSError **)error __attribute__((__swift_error__(null_result))); |
| 24 |
// expected-error@-1 {{'__swift_error__' attribute with 'null_result' convention can only be applied to a method returning a pointer}} |
| 25 |
- (BOOL)m3:(NSError **)error __attribute__((__swift_error__(nonzero_result))); |
| 26 |
- (BOOL)m4:(NSError **)error __attribute__((__swift_error__(zero_result))); |
| 27 |
|
| 28 |
- (Undeclared)n0:(NSError **)error __attribute__((__swift_error__(none))); |
| 29 |
// expected-error@-1 {{expected a type}} |
| 30 |
- (Undeclared)n1:(NSError **)error __attribute__((__swift_error__(nonnull_error))); |
| 31 |
// expected-error@-1 {{expected a type}} |
| 32 |
- (Undeclared)n2:(NSError **)error __attribute__((__swift_error__(null_result))); |
| 33 |
// expected-error@-1 {{expected a type}} |
| 34 |
- (Undeclared)n3:(NSError **)error __attribute__((__swift_error__(nonzero_result))); |
| 35 |
// expected-error@-1 {{expected a type}} |
| 36 |
// FIXME: the follow-on warning should really be suppressed, but apparently |
| 37 |
// having an ill-formed return type doesn't mark anything as invalid. |
| 38 |
// expected-error@-4 {{can only be applied}} |
| 39 |
- (Undeclared)n4:(NSError **)error __attribute__((__swift_error__(zero_result))); |
| 40 |
// expected-error@-1 {{expected a type}} |
| 41 |
// FIXME: the follow-on warning should really be suppressed, but apparently |
| 42 |
// having an ill-formed return type doesn't mark anything as invalid. |
| 43 |
// expected-error@-4 {{can only be applied}} |
| 44 |
|
| 45 |
- (instancetype)o0 __attribute__((__swift_error__(none))); |
| 46 |
- (instancetype)o1 __attribute__((__swift_error__(nonnull_error))); |
| 47 |
// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}} |
| 48 |
- (instancetype)o2 __attribute__((__swift_error__(null_result))); |
| 49 |
// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}} |
| 50 |
- (instancetype)o3 __attribute__((__swift_error__(nonzero_result))); |
| 51 |
// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}} |
| 52 |
- (instancetype)o4 __attribute__((__swift_error__(zero_result))); |
| 53 |
// expected-error@-1 {{'__swift_error__' attribute can only be applied to a method with an error parameter}} |
| 54 |
@end |
| 55 |
|
| 56 |
extern BOOL m0(CFErrorRef *) __attribute__((__swift_error__(none))); |
| 57 |
extern BOOL m1(CFErrorRef *) __attribute__((__swift_error__(nonnull_error))); |
| 58 |
extern BOOL m2(CFErrorRef *) __attribute__((__swift_error__(null_result))); |
| 59 |
// expected-error@-1 {{'__swift_error__' attribute with 'null_result' convention can only be applied to a function returning a pointer}} |
| 60 |
extern BOOL m3(CFErrorRef *) __attribute__((__swift_error__(nonzero_result))); |
| 61 |
extern BOOL m4(CFErrorRef *) __attribute__((__swift_error__(zero_result))); |
| 62 |
|
| 63 |
extern Undeclared n0(CFErrorRef *) __attribute__((__swift_error__(none))); |
| 64 |
// expected-error@-1 {{unknown type name 'Undeclared'}} |
| 65 |
extern Undeclared n1(CFErrorRef *) __attribute__((__swift_error__(nonnull_error))); |
| 66 |
// expected-error@-1 {{unknown type name 'Undeclared'}} |
| 67 |
extern Undeclared n2(CFErrorRef *) __attribute__((__swift_error__(null_result))); |
| 68 |
// expected-error@-1 {{unknown type name 'Undeclared'}} |
| 69 |
extern Undeclared n3(CFErrorRef *) __attribute__((__swift_error__(nonzero_result))); |
| 70 |
// expected-error@-1 {{unknown type name 'Undeclared'}} |
| 71 |
extern Undeclared n4(CFErrorRef *) __attribute__((__swift_error__(zero_result))); |
| 72 |
// expected-error@-1 {{unknown type name 'Undeclared'}} |
| 73 |
|
| 74 |
extern void *o0(CFErrorRef *) __attribute__((__swift_error__(none))); |
| 75 |
extern void *o1(CFErrorRef *) __attribute__((__swift_error__(nonnull_error))); |
| 76 |
extern void *o2(CFErrorRef *) __attribute__((__swift_error__(null_result))); |
| 77 |
extern void *o3(CFErrorRef *) __attribute__((__swift_error__(nonzero_result))); |
| 78 |
// expected-error@-1 {{'__swift_error__' attribute with 'nonzero_result' convention can only be applied to a function returning an integral type}} |
| 79 |
extern void *o4(CFErrorRef *) __attribute__((__swift_error__(zero_result))); |
| 80 |
// expected-error@-1 {{'__swift_error__' attribute with 'zero_result' convention can only be applied to a function returning an integral type}} |
| 81 |
|
| 82 |
extern void *p0(void) __attribute__((__swift_error__(none))); |
| 83 |
extern void *p1(void) __attribute__((__swift_error__(nonnull_error))); |
| 84 |
// expected-error@-1 {{'__swift_error__' attribute can only be applied to a function with an error parameter}} |
| 85 |
extern void *p2(void) __attribute__((__swift_error__(null_result))); |
| 86 |
// expected-error@-1 {{'__swift_error__' attribute can only be applied to a function with an error parameter}} |
| 87 |
extern void *p3(void) __attribute__((__swift_error__(nonzero_result))); |
| 88 |
// expected-error@-1 {{'__swift_error__' attribute can only be applied to a function with an error parameter}} |
| 89 |
extern void *p4(void) __attribute__((__swift_error__(zero_result))); |
| 90 |
// expected-error@-1 {{'__swift_error__' attribute can only be applied to a function with an error parameter}} |
| 91 |
|
| 92 |
extern BOOL b __attribute__((__swift_error__(none))); |
| 93 |
// expected-error@-1 {{attribute only applies to functions and Objective-C methods}} |