1// RUN: %clang_analyze_cc1 -verify -Wno-objc-root-class %s \
2// RUN:   -analyzer-checker=core,osx.cocoa.RetainCount
3
4#define NULL 0
5#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
6#define CF_CONSUMED __attribute__((cf_consumed))
7
8void clang_analyzer_eval(int);
9
10typedef const void *CFTypeRef;
11
12extern CFTypeRef CFCreate() CF_RETURNS_RETAINED;
13extern CFTypeRef CFRetain(CFTypeRef cf);
14extern void CFRelease(CFTypeRef cf);
15
16void bar(CFTypeRef *v) {}
17
18void test1() {
19  CFTypeRef *values = (CFTypeRef[]){
20      CFCreate(),  // no-warning
21      CFCreate(),  // expected-warning{{leak}}
22      CFCreate()}; // no-warning
23  CFRelease(values[0]);
24  CFRelease(values[2]);
25}
26