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