Home | History | Annotate | Download | only in SemaObjCXX
      1 // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-nonfragile-abi -fobjc-runtime-has-weak -verify %s
      2 
      3 // Check the results of the various type-trait query functions on
      4 // lifetime-qualified types in ARC.
      5 
      6 #define JOIN3(X,Y) X ## Y
      7 #define JOIN2(X,Y) JOIN3(X,Y)
      8 #define JOIN(X,Y) JOIN2(X,Y)
      9 
     10 #define TRAIT_IS_TRUE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? 1 : -1]
     11 #define TRAIT_IS_FALSE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? -1 : 1]
     12   
     13 // __has_nothrow_assign
     14 TRAIT_IS_TRUE(__has_nothrow_assign, __strong id);
     15 TRAIT_IS_TRUE(__has_nothrow_assign, __weak id);
     16 TRAIT_IS_TRUE(__has_nothrow_assign, __autoreleasing id);
     17 TRAIT_IS_TRUE(__has_nothrow_assign, __unsafe_unretained id);
     18 
     19 // __has_nothrow_copy
     20 TRAIT_IS_TRUE(__has_nothrow_copy, __strong id);
     21 TRAIT_IS_TRUE(__has_nothrow_copy, __weak id);
     22 TRAIT_IS_TRUE(__has_nothrow_copy, __autoreleasing id);
     23 TRAIT_IS_TRUE(__has_nothrow_copy, __unsafe_unretained id);
     24 
     25 // __has_nothrow_constructor
     26 TRAIT_IS_TRUE(__has_nothrow_constructor, __strong id);
     27 TRAIT_IS_TRUE(__has_nothrow_constructor, __weak id);
     28 TRAIT_IS_TRUE(__has_nothrow_constructor, __autoreleasing id);
     29 TRAIT_IS_TRUE(__has_nothrow_constructor, __unsafe_unretained id);
     30 
     31 // __has_trivial_assign
     32 TRAIT_IS_FALSE(__has_trivial_assign, __strong id);
     33 TRAIT_IS_FALSE(__has_trivial_assign, __weak id);
     34 TRAIT_IS_FALSE(__has_trivial_assign, __autoreleasing id);
     35 TRAIT_IS_TRUE(__has_trivial_assign, __unsafe_unretained id);
     36 
     37 // __has_trivial_copy
     38 TRAIT_IS_FALSE(__has_trivial_copy, __strong id);
     39 TRAIT_IS_FALSE(__has_trivial_copy, __weak id);
     40 TRAIT_IS_FALSE(__has_trivial_copy, __autoreleasing id);
     41 TRAIT_IS_TRUE(__has_trivial_copy, __unsafe_unretained id);
     42 
     43 // __has_trivial_constructor
     44 TRAIT_IS_FALSE(__has_trivial_constructor, __strong id);
     45 TRAIT_IS_FALSE(__has_trivial_constructor, __weak id);
     46 TRAIT_IS_FALSE(__has_trivial_constructor, __autoreleasing id);
     47 TRAIT_IS_TRUE(__has_trivial_constructor, __unsafe_unretained id);
     48 
     49 // __has_trivial_destructor
     50 TRAIT_IS_FALSE(__has_trivial_destructor, __strong id);
     51 TRAIT_IS_FALSE(__has_trivial_destructor, __weak id);
     52 TRAIT_IS_TRUE(__has_trivial_destructor, __autoreleasing id);
     53 TRAIT_IS_TRUE(__has_trivial_destructor, __unsafe_unretained id);
     54 
     55 // __is_literal
     56 TRAIT_IS_FALSE(__is_literal, __strong id);
     57 TRAIT_IS_FALSE(__is_literal, __weak id);
     58 TRAIT_IS_FALSE(__is_literal, __autoreleasing id);
     59 TRAIT_IS_FALSE(__is_literal, __unsafe_unretained id);
     60 
     61 // __is_literal_type
     62 TRAIT_IS_FALSE(__is_literal_type, __strong id);
     63 TRAIT_IS_FALSE(__is_literal_type, __weak id);
     64 TRAIT_IS_FALSE(__is_literal_type, __autoreleasing id);
     65 TRAIT_IS_FALSE(__is_literal_type, __unsafe_unretained id);
     66 
     67 // __is_pod
     68 TRAIT_IS_FALSE(__is_pod, __strong id);
     69 TRAIT_IS_FALSE(__is_pod, __weak id);
     70 TRAIT_IS_FALSE(__is_pod, __autoreleasing id);
     71 TRAIT_IS_TRUE(__is_pod, __unsafe_unretained id);
     72 
     73 // __is_trivial
     74 TRAIT_IS_FALSE(__is_trivial, __strong id);
     75 TRAIT_IS_FALSE(__is_trivial, __weak id);
     76 TRAIT_IS_FALSE(__is_trivial, __autoreleasing id);
     77 TRAIT_IS_TRUE(__is_trivial, __unsafe_unretained id);
     78 
     79 // __is_scalar
     80 TRAIT_IS_FALSE(__is_scalar, __strong id);
     81 TRAIT_IS_FALSE(__is_scalar, __weak id);
     82 TRAIT_IS_FALSE(__is_scalar, __autoreleasing id);
     83 TRAIT_IS_TRUE(__is_scalar, __unsafe_unretained id);
     84 
     85 // __is_standard_layout
     86 TRAIT_IS_TRUE(__is_standard_layout, __strong id);
     87 TRAIT_IS_TRUE(__is_standard_layout, __weak id);
     88 TRAIT_IS_TRUE(__is_standard_layout, __autoreleasing id);
     89 TRAIT_IS_TRUE(__is_standard_layout, __unsafe_unretained id);
     90 
     91