brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.6 KiB · 0132a8b Raw
94 lines · plain
1// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s2 3@class NSError;4 5#if __SIZEOF_POINTER__ == 46typedef unsigned char BOOL;7#else8typedef _Bool BOOL;9#endif10 11typedef struct __attribute__((__objc_bridge__(NSError))) __CFError *CFErrorRef;12 13extern int f0(void) __attribute__((__swift_error__));14// expected-error@-1 {{'__swift_error__' attribute takes one argument}}15extern int f1(void) __attribute__((__swift_error__(invalid)));16// expected-warning@-1 {{'__swift_error__' attribute argument not supported: 'invalid'}}17extern int f2(void) __attribute__((__swift_error__(none,zero_result)));18// expected-error@-1 {{use of undeclared identifier 'zero_result'}}19 20@interface Erroneous21- (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 apparently37// 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 apparently42// 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@end55 56extern BOOL m0(CFErrorRef *) __attribute__((__swift_error__(none)));57extern BOOL m1(CFErrorRef *) __attribute__((__swift_error__(nonnull_error)));58extern 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}}60extern BOOL m3(CFErrorRef *) __attribute__((__swift_error__(nonzero_result)));61extern BOOL m4(CFErrorRef *) __attribute__((__swift_error__(zero_result)));62 63extern Undeclared n0(CFErrorRef *) __attribute__((__swift_error__(none)));64// expected-error@-1 {{unknown type name 'Undeclared'}}65extern Undeclared n1(CFErrorRef *) __attribute__((__swift_error__(nonnull_error)));66// expected-error@-1 {{unknown type name 'Undeclared'}}67extern Undeclared n2(CFErrorRef *) __attribute__((__swift_error__(null_result)));68// expected-error@-1 {{unknown type name 'Undeclared'}}69extern Undeclared n3(CFErrorRef *) __attribute__((__swift_error__(nonzero_result)));70// expected-error@-1 {{unknown type name 'Undeclared'}}71extern Undeclared n4(CFErrorRef *) __attribute__((__swift_error__(zero_result)));72// expected-error@-1 {{unknown type name 'Undeclared'}}73 74extern void *o0(CFErrorRef *) __attribute__((__swift_error__(none)));75extern void *o1(CFErrorRef *) __attribute__((__swift_error__(nonnull_error)));76extern void *o2(CFErrorRef *) __attribute__((__swift_error__(null_result)));77extern 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}}79extern 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 82extern void *p0(void) __attribute__((__swift_error__(none)));83extern 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}}85extern 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}}87extern 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}}89extern 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 92extern BOOL b __attribute__((__swift_error__(none)));93// expected-error@-1 {{attribute only applies to functions and Objective-C methods}}94