150
|
1 // RUN: %clang_cc1 -std=c++11 -fobjc-runtime-has-weak -fobjc-weak -fobjc-arc -fsyntax-only -verify %s
|
|
2
|
|
3 void __attribute__((trivial_abi)) foo(); // expected-warning {{'trivial_abi' attribute only applies to classes}}
|
|
4
|
|
5 struct [[clang::trivial_abi]] S0 {
|
|
6 int a;
|
|
7 };
|
|
8
|
|
9 struct __attribute__((trivial_abi)) S1 {
|
|
10 int a;
|
|
11 };
|
|
12
|
221
|
13 struct __attribute__((trivial_abi)) S2 { // expected-warning {{'trivial_abi' cannot be applied to 'S2'}} expected-note {{has a __weak field}}
|
150
|
14 __weak id a;
|
|
15 };
|
|
16
|
221
|
17 struct __attribute__((trivial_abi)) S3 { // expected-warning {{'trivial_abi' cannot be applied to 'S3'}} expected-note {{is polymorphic}}
|
150
|
18 virtual void m();
|
|
19 };
|
|
20
|
|
21 struct S3_2 {
|
|
22 virtual void m();
|
221
|
23 } __attribute__((trivial_abi)); // expected-warning {{'trivial_abi' cannot be applied to 'S3_2'}} expected-note {{is polymorphic}}
|
150
|
24
|
|
25 struct S4 {
|
|
26 int a;
|
|
27 };
|
|
28
|
221
|
29 struct __attribute__((trivial_abi)) S5 : public virtual S4 { // expected-warning {{'trivial_abi' cannot be applied to 'S5'}} expected-note {{has a virtual base}}
|
150
|
30 };
|
|
31
|
|
32 struct __attribute__((trivial_abi)) S9 : public S4 {
|
|
33 };
|
|
34
|
|
35 struct S6 {
|
|
36 __weak id a;
|
|
37 };
|
|
38
|
221
|
39 struct __attribute__((trivial_abi)) S12 { // expected-warning {{'trivial_abi' cannot be applied to 'S12'}} expected-note {{has a __weak field}}
|
150
|
40 __weak id a;
|
|
41 };
|
|
42
|
221
|
43 struct __attribute__((trivial_abi)) S13 { // expected-warning {{'trivial_abi' cannot be applied to 'S13'}} expected-note {{has a __weak field}}
|
150
|
44 __weak id a[2];
|
|
45 };
|
|
46
|
221
|
47 struct __attribute__((trivial_abi)) S7 { // expected-warning {{'trivial_abi' cannot be applied to 'S7'}} expected-note {{has a field of a non-trivial class type}}
|
150
|
48 S6 a;
|
|
49 };
|
|
50
|
221
|
51 struct __attribute__((trivial_abi)) S11 { // expected-warning {{'trivial_abi' cannot be applied to 'S11'}} expected-note {{has a field of a non-trivial class type}}
|
150
|
52 S6 a[2];
|
|
53 };
|
|
54
|
|
55 struct __attribute__((trivial_abi(1))) S8 { // expected-error {{'trivial_abi' attribute takes no arguments}}
|
|
56 int a;
|
|
57 };
|
|
58
|
|
59 // Do not warn when 'trivial_abi' is used to annotate a template class.
|
221
|
60 template <class T>
|
150
|
61 struct __attribute__((trivial_abi)) S10 {
|
|
62 T p;
|
|
63 };
|
|
64
|
|
65 S10<int *> p1;
|
|
66 S10<__weak id> p2;
|
|
67
|
|
68 template<>
|
221
|
69 struct __attribute__((trivial_abi)) S10<id> { // expected-warning {{'trivial_abi' cannot be applied to 'S10<id>'}} expected-note {{has a __weak field}}
|
150
|
70 __weak id a;
|
|
71 };
|
|
72
|
|
73 template<class T>
|
|
74 struct S14 {
|
|
75 T a;
|
|
76 __weak id b;
|
|
77 };
|
|
78
|
221
|
79 template <class T>
|
150
|
80 struct __attribute__((trivial_abi)) S15 : S14<T> {
|
|
81 };
|
|
82
|
|
83 S15<int> s15;
|
|
84
|
221
|
85 template <class T>
|
150
|
86 struct __attribute__((trivial_abi)) S16 {
|
|
87 S14<T> a;
|
|
88 };
|
|
89
|
|
90 S16<int> s16;
|
|
91
|
221
|
92 template <class T>
|
|
93 struct __attribute__((trivial_abi)) S17 { // expected-warning {{'trivial_abi' cannot be applied to 'S17'}} expected-note {{has a __weak field}}
|
|
94 S17();
|
|
95 S17(S17 &&);
|
|
96 __weak id a;
|
|
97 };
|
|
98
|
|
99 struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{has a __weak field}}
|
150
|
100 __weak id a;
|
|
101 };
|
|
102
|
|
103 S17<int> s17;
|
221
|
104
|
|
105 namespace deletedCopyMoveConstructor {
|
|
106 struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
|
|
107 CopyMoveDeleted(const CopyMoveDeleted &) = delete;
|
|
108 CopyMoveDeleted(CopyMoveDeleted &&) = delete;
|
|
109 };
|
|
110
|
|
111 struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
|
|
112 CopyMoveDeleted a;
|
|
113 };
|
|
114
|
|
115 struct __attribute__((trivial_abi)) CopyDeleted {
|
|
116 CopyDeleted(const CopyDeleted &) = delete;
|
|
117 CopyDeleted(CopyDeleted &&) = default;
|
|
118 };
|
|
119
|
|
120 struct __attribute__((trivial_abi)) MoveDeleted {
|
|
121 MoveDeleted(const MoveDeleted &) = default;
|
|
122 MoveDeleted(MoveDeleted &&) = delete;
|
|
123 };
|
|
124
|
|
125 struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
|
|
126 CopyDeleted a;
|
|
127 MoveDeleted b;
|
|
128 };
|
|
129
|
|
130 // This is fine since the move constructor isn't deleted.
|
|
131 struct __attribute__((trivial_abi)) S20 {
|
|
132 int &&a; // a member of rvalue reference type deletes the copy constructor.
|
|
133 };
|
|
134 }
|