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