| Fariborz Jahanian | 35227ea | 2012-09-14 17:48:35 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fsyntax-only -fblocks %s |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 2 | |
| 3 | // Classes that have an Objective-C object pointer. |
| Fariborz Jahanian | 35227ea | 2012-09-14 17:48:35 +0000 | [diff] [blame] | 4 | struct HasObjectMember0 { |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 5 | id x; |
| 6 | }; |
| 7 | |
| Fariborz Jahanian | 35227ea | 2012-09-14 17:48:35 +0000 | [diff] [blame] | 8 | struct HasObjectMember1 { |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 9 | id x[3]; |
| 10 | }; |
| 11 | |
| Fariborz Jahanian | 35227ea | 2012-09-14 17:48:35 +0000 | [diff] [blame] | 12 | struct HasObjectMember2 { |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 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 | |
| Fariborz Jahanian | 35227ea | 2012-09-14 17:48:35 +0000 | [diff] [blame] | 29 | struct HasBlockPointerMember0 { |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 30 | int (^bp)(int); |
| 31 | }; |
| 32 | |
| Fariborz Jahanian | 35227ea | 2012-09-14 17:48:35 +0000 | [diff] [blame] | 33 | struct HasBlockPointerMember1 { |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 34 | int (^bp[2][3])(int); |
| 35 | }; |
| 36 | |
| 37 | struct NonPOD { |
| 38 | NonPOD(const NonPOD&); |
| 39 | }; |
| 40 | |
| Fariborz Jahanian | 35227ea | 2012-09-14 17:48:35 +0000 | [diff] [blame] | 41 | struct HasObjectMemberAndNonPOD0 { |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 42 | id x; |
| 43 | NonPOD np; |
| 44 | }; |
| 45 | |
| Fariborz Jahanian | 35227ea | 2012-09-14 17:48:35 +0000 | [diff] [blame] | 46 | struct HasObjectMemberAndNonPOD1 { |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 47 | NonPOD np; |
| 48 | id x[3]; |
| 49 | }; |
| 50 | |
| Fariborz Jahanian | 35227ea | 2012-09-14 17:48:35 +0000 | [diff] [blame] | 51 | struct HasObjectMemberAndNonPOD2 { |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 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 | |
| Fariborz Jahanian | 35227ea | 2012-09-14 17:48:35 +0000 | [diff] [blame] | 63 | struct HasBlockPointerMemberAndNonPOD0 { |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 64 | NonPOD np; |
| 65 | int (^bp)(int); |
| 66 | }; |
| 67 | |
| Fariborz Jahanian | 35227ea | 2012-09-14 17:48:35 +0000 | [diff] [blame] | 68 | struct HasBlockPointerMemberAndNonPOD1 { |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 69 | NonPOD np; |
| 70 | int (^bp[2][3])(int); |
| 71 | }; |
| 72 | |
| Douglas Gregor | 7e6bfb4 | 2011-07-12 17:28:52 +0000 | [diff] [blame] | 73 | int check_non_pod_objc_pointer0[__is_pod(id)? 1 : -1]; |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 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]; |
| Douglas Gregor | 7e6bfb4 | 2011-07-12 17:28:52 +0000 | [diff] [blame] | 76 | int check_non_pod_objc_pointer3[__is_pod(id[2][3])? 1 : -1]; |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 77 | int check_non_pod_objc_pointer4[__is_pod(__unsafe_unretained id[2][3])? 1 : -1]; |
| Douglas Gregor | 7e6bfb4 | 2011-07-12 17:28:52 +0000 | [diff] [blame] | 78 | int check_non_pod_block0[__is_pod(int (^)(int))? 1 : -1]; |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 79 | int check_non_pod_block1[__is_pod(int (^ __unsafe_unretained)(int))? 1 : -1]; |
| 80 | |
| 81 | struct FlexibleArrayMember0 { |
| 82 | int length; |
| Richard Smith | 6fa28ff | 2014-01-11 00:53:35 +0000 | [diff] [blame] | 83 | id array[]; // expected-error{{flexible array member 'array' of type 'id __strong[]' with non-trivial destruction}} |
| John McCall | d70fb98 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 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 | } |