• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
14TRAIT_IS_TRUE(__has_nothrow_assign, __strong id);
15TRAIT_IS_TRUE(__has_nothrow_assign, __weak id);
16TRAIT_IS_TRUE(__has_nothrow_assign, __autoreleasing id);
17TRAIT_IS_TRUE(__has_nothrow_assign, __unsafe_unretained id);
18
19// __has_nothrow_copy
20TRAIT_IS_TRUE(__has_nothrow_copy, __strong id);
21TRAIT_IS_TRUE(__has_nothrow_copy, __weak id);
22TRAIT_IS_TRUE(__has_nothrow_copy, __autoreleasing id);
23TRAIT_IS_TRUE(__has_nothrow_copy, __unsafe_unretained id);
24
25// __has_nothrow_constructor
26TRAIT_IS_TRUE(__has_nothrow_constructor, __strong id);
27TRAIT_IS_TRUE(__has_nothrow_constructor, __weak id);
28TRAIT_IS_TRUE(__has_nothrow_constructor, __autoreleasing id);
29TRAIT_IS_TRUE(__has_nothrow_constructor, __unsafe_unretained id);
30
31// __has_trivial_assign
32TRAIT_IS_FALSE(__has_trivial_assign, __strong id);
33TRAIT_IS_FALSE(__has_trivial_assign, __weak id);
34TRAIT_IS_FALSE(__has_trivial_assign, __autoreleasing id);
35TRAIT_IS_TRUE(__has_trivial_assign, __unsafe_unretained id);
36
37// __has_trivial_copy
38TRAIT_IS_FALSE(__has_trivial_copy, __strong id);
39TRAIT_IS_FALSE(__has_trivial_copy, __weak id);
40TRAIT_IS_FALSE(__has_trivial_copy, __autoreleasing id);
41TRAIT_IS_TRUE(__has_trivial_copy, __unsafe_unretained id);
42
43// __has_trivial_constructor
44TRAIT_IS_FALSE(__has_trivial_constructor, __strong id);
45TRAIT_IS_FALSE(__has_trivial_constructor, __weak id);
46TRAIT_IS_FALSE(__has_trivial_constructor, __autoreleasing id);
47TRAIT_IS_TRUE(__has_trivial_constructor, __unsafe_unretained id);
48
49// __has_trivial_destructor
50TRAIT_IS_FALSE(__has_trivial_destructor, __strong id);
51TRAIT_IS_FALSE(__has_trivial_destructor, __weak id);
52TRAIT_IS_TRUE(__has_trivial_destructor, __autoreleasing id);
53TRAIT_IS_TRUE(__has_trivial_destructor, __unsafe_unretained id);
54
55// __is_literal
56TRAIT_IS_FALSE(__is_literal, __strong id);
57TRAIT_IS_FALSE(__is_literal, __weak id);
58TRAIT_IS_FALSE(__is_literal, __autoreleasing id);
59TRAIT_IS_FALSE(__is_literal, __unsafe_unretained id);
60
61// __is_literal_type
62TRAIT_IS_FALSE(__is_literal_type, __strong id);
63TRAIT_IS_FALSE(__is_literal_type, __weak id);
64TRAIT_IS_FALSE(__is_literal_type, __autoreleasing id);
65TRAIT_IS_FALSE(__is_literal_type, __unsafe_unretained id);
66
67// __is_pod
68TRAIT_IS_FALSE(__is_pod, __strong id);
69TRAIT_IS_FALSE(__is_pod, __weak id);
70TRAIT_IS_FALSE(__is_pod, __autoreleasing id);
71TRAIT_IS_TRUE(__is_pod, __unsafe_unretained id);
72
73// __is_trivial
74TRAIT_IS_FALSE(__is_trivial, __strong id);
75TRAIT_IS_FALSE(__is_trivial, __weak id);
76TRAIT_IS_FALSE(__is_trivial, __autoreleasing id);
77TRAIT_IS_TRUE(__is_trivial, __unsafe_unretained id);
78
79// __is_scalar
80TRAIT_IS_FALSE(__is_scalar, __strong id);
81TRAIT_IS_FALSE(__is_scalar, __weak id);
82TRAIT_IS_FALSE(__is_scalar, __autoreleasing id);
83TRAIT_IS_TRUE(__is_scalar, __unsafe_unretained id);
84
85// __is_standard_layout
86TRAIT_IS_TRUE(__is_standard_layout, __strong id);
87TRAIT_IS_TRUE(__is_standard_layout, __weak id);
88TRAIT_IS_TRUE(__is_standard_layout, __autoreleasing id);
89TRAIT_IS_TRUE(__is_standard_layout, __unsafe_unretained id);
90
91