]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ARCMT/cxx-checking.mm
Vendor import of clang release_30 branch r142614:
[FreeBSD/FreeBSD.git] / test / ARCMT / cxx-checking.mm
1 // RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fsyntax-only -fblocks -Warc-abi  %s
2
3 // Classes that have an Objective-C object pointer.
4 struct HasObjectMember0 { // expected-warning{{'HasObjectMember0' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
5   id x;
6 };
7
8 struct HasObjectMember1 { // expected-warning{{'HasObjectMember1' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
9   id x[3];
10 };
11
12 struct HasObjectMember2 { // expected-warning{{'HasObjectMember2' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
13   id x[3][2];
14 };
15
16 // Don't complain if the type has non-external linkage
17 namespace {
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.
25 struct HasObjectMember3 { 
26   __unsafe_unretained id x[3][2];
27 };
28
29 struct HasBlockPointerMember0 { // expected-warning{{'HasBlockPointerMember0' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
30   int (^bp)(int);
31 };
32
33 struct HasBlockPointerMember1 { // expected-warning{{'HasBlockPointerMember1' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
34   int (^bp[2][3])(int);
35 };
36
37 struct NonPOD {
38   NonPOD(const NonPOD&);
39 };
40
41 struct HasObjectMemberAndNonPOD0 { // expected-warning{{'HasObjectMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
42   // expected-warning{{'HasObjectMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
43   id x;
44   NonPOD np;
45 };
46
47 struct HasObjectMemberAndNonPOD1 { // expected-warning{{'HasObjectMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
48   // expected-warning{{'HasObjectMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
49   NonPOD np;
50   id x[3];
51 };
52
53 struct HasObjectMemberAndNonPOD2 { // expected-warning{{'HasObjectMemberAndNonPOD2' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
54   // expected-warning{{'HasObjectMemberAndNonPOD2' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
55   NonPOD np;
56   id x[3][2];
57 };
58
59 struct HasObjectMemberAndNonPOD3 {
60   HasObjectMemberAndNonPOD3 &operator=(const HasObjectMemberAndNonPOD3&);
61   ~HasObjectMemberAndNonPOD3();
62   NonPOD np;
63   id x[3][2];
64 };
65
66 struct HasBlockPointerMemberAndNonPOD0 { // expected-warning{{'HasBlockPointerMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
67 // expected-warning{{'HasBlockPointerMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
68   NonPOD np;
69   int (^bp)(int);
70 };
71
72 struct HasBlockPointerMemberAndNonPOD1 { // expected-warning{{'HasBlockPointerMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
73 // expected-warning{{'HasBlockPointerMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
74   NonPOD np;
75   int (^bp[2][3])(int);
76 };
77
78 int check_non_pod_objc_pointer0[__is_pod(id)? 1 : -1];
79 int check_non_pod_objc_pointer1[__is_pod(__strong id)? -1 : 1];
80 int check_non_pod_objc_pointer2[__is_pod(__unsafe_unretained id)? 1 : -1];
81 int check_non_pod_objc_pointer3[__is_pod(id[2][3])? 1 : -1];
82 int check_non_pod_objc_pointer4[__is_pod(__unsafe_unretained id[2][3])? 1 : -1];
83 int check_non_pod_block0[__is_pod(int (^)(int))? 1 : -1];
84 int check_non_pod_block1[__is_pod(int (^ __unsafe_unretained)(int))? 1 : -1];
85
86 struct FlexibleArrayMember0 {
87   int length;
88   id array[]; // expected-error{{flexible array member 'array' of non-POD element type 'id __strong[]'}}
89 };
90
91 struct FlexibleArrayMember1 {
92   int length;
93   __unsafe_unretained id array[];
94 };
95
96 // It's okay to pass a retainable type through an ellipsis.
97 void variadic(...);
98 void test_variadic() {
99   variadic(1, 17, @"Foo");
100 }
101
102 // It's okay to create a VLA of retainable types.
103 void vla(int n) {
104   id vla[n];
105 }