1// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fsyntax-only -fblocks %s
2
3// Classes that have an Objective-C object pointer.
4struct HasObjectMember0 {
5  id x;
6};
7
8struct HasObjectMember1 {
9  id x[3];
10};
11
12struct HasObjectMember2 {
13  id x[3][2];
14};
15
16// Don't complain if the type has non-external linkage
17namespace {
18  struct HasObjectMember3 {
19    id x[3][2];
20  };
21}
22
23// Don't complain if the Objective-C pointer type was explicitly given
24// no lifetime.
25struct HasObjectMember3 {
26  __unsafe_unretained id x[3][2];
27};
28
29struct HasBlockPointerMember0 {
30  int (^bp)(int);
31};
32
33struct HasBlockPointerMember1 {
34  int (^bp[2][3])(int);
35};
36
37struct NonPOD {
38  NonPOD(const NonPOD&);
39};
40
41struct HasObjectMemberAndNonPOD0 {
42  id x;
43  NonPOD np;
44};
45
46struct HasObjectMemberAndNonPOD1 {
47  NonPOD np;
48  id x[3];
49};
50
51struct HasObjectMemberAndNonPOD2 {
52  NonPOD np;
53  id x[3][2];
54};
55
56struct HasObjectMemberAndNonPOD3 {
57  HasObjectMemberAndNonPOD3 &operator=(const HasObjectMemberAndNonPOD3&);
58  ~HasObjectMemberAndNonPOD3();
59  NonPOD np;
60  id x[3][2];
61};
62
63struct HasBlockPointerMemberAndNonPOD0 {
64  NonPOD np;
65  int (^bp)(int);
66};
67
68struct HasBlockPointerMemberAndNonPOD1 {
69  NonPOD np;
70  int (^bp[2][3])(int);
71};
72
73int check_non_pod_objc_pointer0[__is_pod(id)? 1 : -1];
74int check_non_pod_objc_pointer1[__is_pod(__strong id)? -1 : 1];
75int check_non_pod_objc_pointer2[__is_pod(__unsafe_unretained id)? 1 : -1];
76int check_non_pod_objc_pointer3[__is_pod(id[2][3])? 1 : -1];
77int check_non_pod_objc_pointer4[__is_pod(__unsafe_unretained id[2][3])? 1 : -1];
78int check_non_pod_block0[__is_pod(int (^)(int))? 1 : -1];
79int check_non_pod_block1[__is_pod(int (^ __unsafe_unretained)(int))? 1 : -1];
80
81struct FlexibleArrayMember0 {
82  int length;
83  id array[]; // expected-error{{flexible array member 'array' of type 'id __strong[]' with non-trivial destruction}}
84};
85
86struct FlexibleArrayMember1 {
87  int length;
88  __unsafe_unretained id array[];
89};
90
91// It's okay to pass a retainable type through an ellipsis.
92void variadic(...);
93void test_variadic() {
94  variadic(1, 17, @"Foo");
95}
96
97// It's okay to create a VLA of retainable types.
98void vla(int n) {
99  id vla[n];
100}
101