reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
// RUN: %clang_cc1 -fsyntax-only -fobjc-weak -fobjc-runtime-has-weak -verify -std=c++11 %s
// expected-no-diagnostics

// Check the results of the various type-trait query functions on
// lifetime-qualified types in ObjC Weak.

#define TRAIT_IS_TRUE(Trait, Type) static_assert(Trait(Type), "")
#define TRAIT_IS_FALSE(Trait, Type) static_assert(!Trait(Type), "")
#define TRAIT_IS_TRUE_2(Trait, Type1, Type2) static_assert(Trait(Type1, Type2), "")
#define TRAIT_IS_FALSE_2(Trait, Type1, Type2) static_assert(!Trait(Type1, Type2), "")
  
struct HasStrong { id obj; };
struct HasWeak { __weak id obj; };
struct HasUnsafeUnretained { __unsafe_unretained id obj; };

// __has_nothrow_assign
TRAIT_IS_TRUE(__has_nothrow_assign, __strong id);
TRAIT_IS_TRUE(__has_nothrow_assign, __weak id);
TRAIT_IS_TRUE(__has_nothrow_assign, __autoreleasing id);
TRAIT_IS_TRUE(__has_nothrow_assign, __unsafe_unretained id);
TRAIT_IS_TRUE(__has_nothrow_assign, HasStrong);
TRAIT_IS_TRUE(__has_nothrow_assign, HasWeak);
TRAIT_IS_TRUE(__has_nothrow_assign, HasUnsafeUnretained);

// __has_nothrow_copy
TRAIT_IS_TRUE(__has_nothrow_copy, __strong id);
TRAIT_IS_TRUE(__has_nothrow_copy, __weak id);
TRAIT_IS_TRUE(__has_nothrow_copy, __autoreleasing id);
TRAIT_IS_TRUE(__has_nothrow_copy, __unsafe_unretained id);
TRAIT_IS_TRUE(__has_nothrow_copy, HasStrong);
TRAIT_IS_TRUE(__has_nothrow_copy, HasWeak);
TRAIT_IS_TRUE(__has_nothrow_copy, HasUnsafeUnretained);

// __has_nothrow_constructor
TRAIT_IS_TRUE(__has_nothrow_constructor, __strong id);
TRAIT_IS_TRUE(__has_nothrow_constructor, __weak id);
TRAIT_IS_TRUE(__has_nothrow_constructor, __autoreleasing id);
TRAIT_IS_TRUE(__has_nothrow_constructor, __unsafe_unretained id);
TRAIT_IS_TRUE(__has_nothrow_constructor, HasStrong);
TRAIT_IS_TRUE(__has_nothrow_constructor, HasWeak);
TRAIT_IS_TRUE(__has_nothrow_constructor, HasUnsafeUnretained);

// __has_trivial_assign
TRAIT_IS_TRUE(__has_trivial_assign, __strong id);
TRAIT_IS_FALSE(__has_trivial_assign, __weak id);
TRAIT_IS_TRUE(__has_trivial_assign, __autoreleasing id);
TRAIT_IS_TRUE(__has_trivial_assign, __unsafe_unretained id);
TRAIT_IS_TRUE(__has_trivial_assign, HasStrong);
TRAIT_IS_FALSE(__has_trivial_assign, HasWeak);
TRAIT_IS_TRUE(__has_trivial_assign, HasUnsafeUnretained);

// __has_trivial_copy
TRAIT_IS_TRUE(__has_trivial_copy, __strong id);
TRAIT_IS_FALSE(__has_trivial_copy, __weak id);
TRAIT_IS_TRUE(__has_trivial_copy, __autoreleasing id);
TRAIT_IS_TRUE(__has_trivial_copy, __unsafe_unretained id);
TRAIT_IS_TRUE(__has_trivial_copy, HasStrong);
TRAIT_IS_FALSE(__has_trivial_copy, HasWeak);
TRAIT_IS_TRUE(__has_trivial_copy, HasUnsafeUnretained);

// __has_trivial_constructor
TRAIT_IS_TRUE(__has_trivial_constructor, __strong id);
TRAIT_IS_FALSE(__has_trivial_constructor, __weak id);
TRAIT_IS_TRUE(__has_trivial_constructor, __autoreleasing id);
TRAIT_IS_TRUE(__has_trivial_constructor, __unsafe_unretained id);
TRAIT_IS_TRUE(__has_trivial_constructor, HasStrong);
TRAIT_IS_FALSE(__has_trivial_constructor, HasWeak);
TRAIT_IS_TRUE(__has_trivial_constructor, HasUnsafeUnretained);

// __has_trivial_destructor
TRAIT_IS_TRUE(__has_trivial_destructor, __strong id);
TRAIT_IS_FALSE(__has_trivial_destructor, __weak id);
TRAIT_IS_TRUE(__has_trivial_destructor, __autoreleasing id);
TRAIT_IS_TRUE(__has_trivial_destructor, __unsafe_unretained id);
TRAIT_IS_TRUE(__has_trivial_destructor, HasStrong);
TRAIT_IS_FALSE(__has_trivial_destructor, HasWeak);
TRAIT_IS_TRUE(__has_trivial_destructor, HasUnsafeUnretained);

// __is_literal
TRAIT_IS_TRUE(__is_literal, __strong id);
TRAIT_IS_TRUE(__is_literal, __weak id);
TRAIT_IS_TRUE(__is_literal, __autoreleasing id);
TRAIT_IS_TRUE(__is_literal, __unsafe_unretained id);

// __is_literal_type
TRAIT_IS_TRUE(__is_literal_type, __strong id);
TRAIT_IS_TRUE(__is_literal_type, __weak id);
TRAIT_IS_TRUE(__is_literal_type, __autoreleasing id);
TRAIT_IS_TRUE(__is_literal_type, __unsafe_unretained id);

// __is_pod
TRAIT_IS_TRUE(__is_pod, __strong id);
TRAIT_IS_FALSE(__is_pod, __weak id);
TRAIT_IS_TRUE(__is_pod, __autoreleasing id);
TRAIT_IS_TRUE(__is_pod, __unsafe_unretained id);
TRAIT_IS_TRUE(__is_pod, HasStrong);
TRAIT_IS_FALSE(__is_pod, HasWeak);
TRAIT_IS_TRUE(__is_pod, HasUnsafeUnretained);

// __is_trivial
TRAIT_IS_TRUE(__is_trivial, __strong id);
TRAIT_IS_FALSE(__is_trivial, __weak id);
TRAIT_IS_TRUE(__is_trivial, __autoreleasing id);
TRAIT_IS_TRUE(__is_trivial, __unsafe_unretained id);
TRAIT_IS_TRUE(__is_trivial, HasStrong);
TRAIT_IS_FALSE(__is_trivial, HasWeak);
TRAIT_IS_TRUE(__is_trivial, HasUnsafeUnretained);

// __is_scalar
TRAIT_IS_TRUE(__is_scalar, __strong id);
TRAIT_IS_FALSE(__is_scalar, __weak id);
TRAIT_IS_TRUE(__is_scalar, __autoreleasing id);
TRAIT_IS_TRUE(__is_scalar, __unsafe_unretained id);

// __is_standard_layout
TRAIT_IS_TRUE(__is_standard_layout, __strong id);
TRAIT_IS_TRUE(__is_standard_layout, __weak id);
TRAIT_IS_TRUE(__is_standard_layout, __autoreleasing id);
TRAIT_IS_TRUE(__is_standard_layout, __unsafe_unretained id);

// __is_trivally_assignable
TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __strong id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __weak id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __autoreleasing id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __unsafe_unretained id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __strong id&&);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __weak id&&);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __autoreleasing id&&);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __strong id&, __unsafe_unretained id&&);
TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __strong id);
TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __weak id);
TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __autoreleasing id);
TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __unsafe_unretained id);
TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __strong id&&);
TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __weak id&&);
TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __autoreleasing id&&);
TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __unsafe_unretained id&&);

TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __strong id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __weak id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __autoreleasing id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __unsafe_unretained id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __strong id&&);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __weak id&&);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __autoreleasing id&&);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __autoreleasing id&, __unsafe_unretained id&&);

TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __strong id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __weak id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __autoreleasing id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __unsafe_unretained id);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __strong id&&);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __weak id&&);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __autoreleasing id&&);
TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __unsafe_unretained id&&);

TRAIT_IS_TRUE_2(__is_trivially_assignable, HasStrong&, HasStrong);
TRAIT_IS_TRUE_2(__is_trivially_assignable, HasStrong&, HasStrong&&);
TRAIT_IS_FALSE_2(__is_trivially_assignable, HasWeak&, HasWeak);
TRAIT_IS_FALSE_2(__is_trivially_assignable, HasWeak&, HasWeak&&);
TRAIT_IS_TRUE_2(__is_trivially_assignable, HasUnsafeUnretained&, HasUnsafeUnretained);
TRAIT_IS_TRUE_2(__is_trivially_assignable, HasUnsafeUnretained&, HasUnsafeUnretained&&);

// __is_trivally_constructible
TRAIT_IS_TRUE(__is_trivially_constructible, __strong id);
TRAIT_IS_FALSE(__is_trivially_constructible, __weak id);
TRAIT_IS_TRUE(__is_trivially_constructible, __autoreleasing id);
TRAIT_IS_TRUE(__is_trivially_constructible, __unsafe_unretained id);

TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __strong id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __weak id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __autoreleasing id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __unsafe_unretained id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __strong id&&);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __weak id&&);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __autoreleasing id&&);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __strong id, __unsafe_unretained id&&);
TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __strong id);
TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __weak id);
TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __autoreleasing id);
TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __unsafe_unretained id);
TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __strong id&&);
TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __weak id&&);
TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __autoreleasing id&&);
TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __unsafe_unretained id&&);

TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __strong id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __weak id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __autoreleasing id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __unsafe_unretained id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __strong id&&);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __weak id&&);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __autoreleasing id&&);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __autoreleasing id, __unsafe_unretained id&&);

TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __strong id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __weak id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __autoreleasing id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __unsafe_unretained id);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __strong id&&);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __weak id&&);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __autoreleasing id&&);
TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __unsafe_unretained id&&);

TRAIT_IS_TRUE_2(__is_trivially_constructible, HasStrong, HasStrong);
TRAIT_IS_TRUE_2(__is_trivially_constructible, HasStrong, HasStrong&&);
TRAIT_IS_FALSE_2(__is_trivially_constructible, HasWeak, HasWeak);
TRAIT_IS_FALSE_2(__is_trivially_constructible, HasWeak, HasWeak&&);
TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained);
TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained&&);