1 // RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s
3 #if __has_feature(attribute_cf_returns_on_parameters)
5 // expected-error@-1 {{okay!}}
10 #define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
11 #define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
13 int x CF_RETURNS_RETAINED; // expected-warning{{'cf_returns_retained' attribute only applies to functions, methods, and parameters}}
14 int y CF_RETURNS_NOT_RETAINED; // expected-warning{{'cf_returns_not_retained' attribute only applies to functions, methods, and parameters}}
16 typedef struct __CFFoo *CFFooRef;
18 int invalid1(void) CF_RETURNS_RETAINED; // expected-warning{{'cf_returns_retained' attribute only applies to functions that return a pointer}}
19 void invalid2(void) CF_RETURNS_RETAINED; // expected-warning{{'cf_returns_retained' attribute only applies to functions that return a pointer}}
21 CFFooRef valid1(void) CF_RETURNS_RETAINED;
22 id valid2(void) CF_RETURNS_RETAINED;
25 - (int)invalid1 CF_RETURNS_RETAINED; // expected-warning{{'cf_returns_retained' attribute only applies to methods that return a pointer}}
26 - (void)invalid2 CF_RETURNS_RETAINED; // expected-warning{{'cf_returns_retained' attribute only applies to methods that return a pointer}}
28 - (CFFooRef)valid1 CF_RETURNS_RETAINED;
29 - (id)valid2 CF_RETURNS_RETAINED;
31 @property int invalidProp1 CF_RETURNS_RETAINED; // expected-warning{{'cf_returns_retained' attribute only applies to properties that return a pointer}}
32 @property void invalidProp2 CF_RETURNS_RETAINED; // expected-warning{{'cf_returns_retained' attribute only applies to properties that return a pointer}}
34 @property CFFooRef valid1 CF_RETURNS_RETAINED;
35 @property id valid2 CF_RETURNS_RETAINED;
38 void invalidParam(int a CF_RETURNS_RETAINED, // expected-warning{{'cf_returns_retained' attribute only applies to pointer-to-CF-pointer parameters}}
39 int *b CF_RETURNS_RETAINED, // expected-warning{{'cf_returns_retained' attribute only applies to pointer-to-CF-pointer parameters}}
40 id c CF_RETURNS_RETAINED, // expected-warning{{'cf_returns_retained' attribute only applies to pointer-to-CF-pointer parameters}}
41 void *d CF_RETURNS_RETAINED, // expected-warning{{'cf_returns_retained' attribute only applies to pointer-to-CF-pointer parameters}}
42 CFFooRef e CF_RETURNS_RETAINED); // expected-warning{{'cf_returns_retained' attribute only applies to pointer-to-CF-pointer parameters}}
44 void validParam(id *a CF_RETURNS_RETAINED,
45 CFFooRef *b CF_RETURNS_RETAINED,
46 void **c CF_RETURNS_RETAINED);
47 void validParam2(id *a CF_RETURNS_NOT_RETAINED,
48 CFFooRef *b CF_RETURNS_NOT_RETAINED,
49 void **c CF_RETURNS_NOT_RETAINED);