Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaObjC / attr-cf_returns.m
blob8d5da90472a18c987204c59f3ab7facf71231f7f
1 // RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s
3 #if __has_feature(attribute_cf_returns_on_parameters)
4 # error "okay!"
5 // expected-error@-1 {{okay!}}
6 #else
7 # error "uh-oh"
8 #endif
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;
24 @interface Test
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;
36 @end
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);