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