blob: aa3bc466f672deac2fc450105c176fc4f014f66e [file] [log] [blame]
Fariborz Jahanian35227ea2012-09-14 17:48:35 +00001// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fsyntax-only -fblocks %s
John McCalld70fb982011-06-15 23:25:17 +00002
3// Classes that have an Objective-C object pointer.
Fariborz Jahanian35227ea2012-09-14 17:48:35 +00004struct HasObjectMember0 {
John McCalld70fb982011-06-15 23:25:17 +00005 id x;
6};
7
Fariborz Jahanian35227ea2012-09-14 17:48:35 +00008struct HasObjectMember1 {
John McCalld70fb982011-06-15 23:25:17 +00009 id x[3];
10};
11
Fariborz Jahanian35227ea2012-09-14 17:48:35 +000012struct HasObjectMember2 {
John McCalld70fb982011-06-15 23:25:17 +000013 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
Fariborz Jahanian35227ea2012-09-14 17:48:35 +000029struct HasBlockPointerMember0 {
John McCalld70fb982011-06-15 23:25:17 +000030 int (^bp)(int);
31};
32
Fariborz Jahanian35227ea2012-09-14 17:48:35 +000033struct HasBlockPointerMember1 {
John McCalld70fb982011-06-15 23:25:17 +000034 int (^bp[2][3])(int);
35};
36
37struct NonPOD {
38 NonPOD(const NonPOD&);
39};
40
Fariborz Jahanian35227ea2012-09-14 17:48:35 +000041struct HasObjectMemberAndNonPOD0 {
John McCalld70fb982011-06-15 23:25:17 +000042 id x;
43 NonPOD np;
44};
45
Fariborz Jahanian35227ea2012-09-14 17:48:35 +000046struct HasObjectMemberAndNonPOD1 {
John McCalld70fb982011-06-15 23:25:17 +000047 NonPOD np;
48 id x[3];
49};
50
Fariborz Jahanian35227ea2012-09-14 17:48:35 +000051struct HasObjectMemberAndNonPOD2 {
John McCalld70fb982011-06-15 23:25:17 +000052 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
Fariborz Jahanian35227ea2012-09-14 17:48:35 +000063struct HasBlockPointerMemberAndNonPOD0 {
John McCalld70fb982011-06-15 23:25:17 +000064 NonPOD np;
65 int (^bp)(int);
66};
67
Fariborz Jahanian35227ea2012-09-14 17:48:35 +000068struct HasBlockPointerMemberAndNonPOD1 {
John McCalld70fb982011-06-15 23:25:17 +000069 NonPOD np;
70 int (^bp[2][3])(int);
71};
72
Douglas Gregor7e6bfb42011-07-12 17:28:52 +000073int check_non_pod_objc_pointer0[__is_pod(id)? 1 : -1];
John McCalld70fb982011-06-15 23:25:17 +000074int check_non_pod_objc_pointer1[__is_pod(__strong id)? -1 : 1];
75int check_non_pod_objc_pointer2[__is_pod(__unsafe_unretained id)? 1 : -1];
Douglas Gregor7e6bfb42011-07-12 17:28:52 +000076int check_non_pod_objc_pointer3[__is_pod(id[2][3])? 1 : -1];
John McCalld70fb982011-06-15 23:25:17 +000077int check_non_pod_objc_pointer4[__is_pod(__unsafe_unretained id[2][3])? 1 : -1];
Douglas Gregor7e6bfb42011-07-12 17:28:52 +000078int check_non_pod_block0[__is_pod(int (^)(int))? 1 : -1];
John McCalld70fb982011-06-15 23:25:17 +000079int check_non_pod_block1[__is_pod(int (^ __unsafe_unretained)(int))? 1 : -1];
80
81struct FlexibleArrayMember0 {
82 int length;
Richard Smith6fa28ff2014-01-11 00:53:35 +000083 id array[]; // expected-error{{flexible array member 'array' of type 'id __strong[]' with non-trivial destruction}}
John McCalld70fb982011-06-15 23:25:17 +000084};
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}