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