1
1
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
2
+ // RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-windows-msvc -std=c++11
3
+ // RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-scei-ps4 -std=c++11
4
+
2
5
3
6
void __attribute__ ((trivial_abi)) foo(); // expected-warning {{'trivial_abi' attribute only applies to classes}}
4
7
@@ -10,30 +13,38 @@ class __attribute__((trivial_abi)) a { a(a &&); };
10
13
// (And it is only trivially relocatable, currently, if it is trivial for calls.)
11
14
// In this case, it is suppressed by an explicitly defined move constructor.
12
15
// Similar concerns apply to later tests that have #if defined(_WIN64) && !defined(__MINGW32__)
13
- static_assert (!__is_trivially_relocatable(a<int >), "");
16
+ static_assert (!__is_trivially_relocatable(a<int >), ""); // expected-warning{{deprecated}}
17
+ static_assert (!__builtin_is_cpp_trivially_relocatable(a<int >), "");
14
18
#else
15
- static_assert (__is_trivially_relocatable(a<int >), "");
19
+ static_assert (__is_trivially_relocatable(a<int >), ""); // expected-warning{{deprecated}}
20
+ static_assert (!__builtin_is_cpp_trivially_relocatable(a<int >), "");
16
21
#endif
17
22
18
23
struct [[clang::trivial_abi]] S0 {
19
24
int a;
20
25
};
21
- static_assert (__is_trivially_relocatable(S0), "");
26
+ static_assert (__is_trivially_relocatable(S0), ""); // expected-warning{{deprecated}}
27
+ static_assert (__builtin_is_cpp_trivially_relocatable(S0), "");
22
28
23
29
struct __attribute__ ((trivial_abi)) S1 {
24
30
int a;
25
31
};
26
- static_assert (__is_trivially_relocatable(S1), "");
32
+ static_assert (__is_trivially_relocatable(S1), ""); // expected-warning{{deprecated}}
33
+ static_assert (__builtin_is_cpp_trivially_relocatable(S1), "");
34
+
27
35
28
36
struct __attribute__ ((trivial_abi)) S3 { // expected-warning {{'trivial_abi' cannot be applied to 'S3'}} expected-note {{is polymorphic}}
29
37
virtual void m ();
30
38
};
31
- static_assert (!__is_trivially_relocatable(S3), "");
39
+ static_assert (!__is_trivially_relocatable(S3), ""); // expected-warning{{deprecated}}
40
+ static_assert (__builtin_is_cpp_trivially_relocatable(S3), "");
41
+
32
42
33
43
struct S3_2 {
34
44
virtual void m ();
35
45
} __attribute__((trivial_abi)); // expected-warning {{'trivial_abi' cannot be applied to 'S3_2'}} expected-note {{is polymorphic}}
36
- static_assert (!__is_trivially_relocatable(S3_2), "");
46
+ static_assert (!__is_trivially_relocatable(S3_2), ""); // expected-warning{{deprecated}}
47
+ static_assert (__builtin_is_cpp_trivially_relocatable(S3_2), "");
37
48
38
49
struct __attribute__ ((trivial_abi)) S3_3 { // expected-warning {{'trivial_abi' cannot be applied to 'S3_3'}} expected-note {{has a field of a non-trivial class type}}
39
50
S3_3 (S3_3 &&);
@@ -43,9 +54,13 @@ struct __attribute__((trivial_abi)) S3_3 { // expected-warning {{'trivial_abi' c
43
54
// The ClangABI4OrPS4 calling convention kind passes classes in registers if the
44
55
// copy constructor is trivial for calls *or deleted*, while other platforms do
45
56
// not accept deleted constructors.
46
- static_assert (__is_trivially_relocatable(S3_3), "");
57
+ static_assert (__is_trivially_relocatable(S3_3), ""); // expected-warning{{deprecated}}
58
+ static_assert (!__builtin_is_cpp_trivially_relocatable(S3_3), "");
59
+
47
60
#else
48
- static_assert (!__is_trivially_relocatable(S3_3), "");
61
+ static_assert (!__is_trivially_relocatable(S3_3), ""); // expected-warning{{deprecated}}
62
+ static_assert (!__builtin_is_cpp_trivially_relocatable(S3_3), "");
63
+
49
64
#endif
50
65
51
66
// Diagnose invalid trivial_abi even when the type is templated because it has a non-trivial field.
@@ -54,20 +69,28 @@ struct __attribute__((trivial_abi)) S3_4 { // expected-warning {{'trivial_abi' c
54
69
S3_4 (S3_4 &&);
55
70
S3_2 s32;
56
71
};
57
- static_assert (!__is_trivially_relocatable(S3_4<int >), "");
72
+ static_assert (!__is_trivially_relocatable(S3_4<int >), ""); // expected-warning{{deprecated}}
73
+ static_assert (!__builtin_is_cpp_trivially_relocatable(S3_4<int >), "");
74
+
58
75
59
76
struct S4 {
60
77
int a;
61
78
};
62
- static_assert (__is_trivially_relocatable(S4), "");
79
+ static_assert (__is_trivially_relocatable(S4), ""); // expected-warning{{deprecated}}
80
+ static_assert (__builtin_is_cpp_trivially_relocatable(S4), "");
81
+
63
82
64
83
struct __attribute__ ((trivial_abi)) S5 : public virtual S4 { // expected-warning {{'trivial_abi' cannot be applied to 'S5'}} expected-note {{has a virtual base}}
65
84
};
66
- static_assert (!__is_trivially_relocatable(S5), "");
85
+ static_assert (!__is_trivially_relocatable(S5), ""); // expected-warning{{deprecated}}
86
+ static_assert (!__builtin_is_cpp_trivially_relocatable(S5), "");
87
+
67
88
68
89
struct __attribute__ ((trivial_abi)) S9 : public S4 {
69
90
};
70
- static_assert (__is_trivially_relocatable(S9), "");
91
+ static_assert (__is_trivially_relocatable(S9), ""); // expected-warning{{deprecated}}
92
+ static_assert (__builtin_is_cpp_trivially_relocatable(S9), "");
93
+
71
94
72
95
struct __attribute__ ((trivial_abi(1 ))) S8 { // expected-error {{'trivial_abi' attribute takes no arguments}}
73
96
int a;
@@ -80,8 +103,12 @@ struct __attribute__((trivial_abi)) S10 {
80
103
};
81
104
82
105
S10<int *> p1;
83
- static_assert (__is_trivially_relocatable(S10<int >), "");
84
- static_assert (__is_trivially_relocatable(S10<S3>), "");
106
+ static_assert (__is_trivially_relocatable(S10<int >), ""); // expected-warning{{deprecated}}
107
+ static_assert (__builtin_is_cpp_trivially_relocatable(S10<int >), "");
108
+
109
+ static_assert (__is_trivially_relocatable(S10<S3>), ""); // expected-warning{{deprecated}}
110
+ static_assert (__builtin_is_cpp_trivially_relocatable(S10<S3>), "");
111
+
85
112
86
113
template <class T >
87
114
struct S14 {
@@ -93,15 +120,21 @@ struct __attribute__((trivial_abi)) S15 : S14<T> {
93
120
};
94
121
95
122
S15<int > s15;
96
- static_assert (__is_trivially_relocatable(S15<int >), "");
97
- static_assert (__is_trivially_relocatable(S15<S3>), "");
123
+ static_assert (__is_trivially_relocatable(S15<int >), ""); // expected-warning{{deprecated}}
124
+ static_assert (__builtin_is_cpp_trivially_relocatable(S15<int >), "");
125
+
126
+ static_assert (__is_trivially_relocatable(S15<S3>), ""); // expected-warning{{deprecated}}
127
+ static_assert (__builtin_is_cpp_trivially_relocatable(S15<S3>), "");
98
128
99
129
template <class T >
100
130
struct __attribute__ ((trivial_abi)) S16 {
101
131
S14<T> a;
102
132
};
103
- static_assert (__is_trivially_relocatable(S16<int >), "");
104
- static_assert (__is_trivially_relocatable(S16<S3>), "");
133
+ static_assert (__is_trivially_relocatable(S16<int >), ""); // expected-warning{{deprecated}}
134
+ static_assert (__builtin_is_cpp_trivially_relocatable(S16<int >), "");
135
+
136
+ static_assert (__is_trivially_relocatable(S16<S3>), ""); // expected-warning{{deprecated}}
137
+ static_assert (__builtin_is_cpp_trivially_relocatable(S16<S3>), "");
105
138
106
139
S16<int > s16;
107
140
@@ -110,62 +143,81 @@ struct __attribute__((trivial_abi)) S17 {
110
143
};
111
144
112
145
S17<int > s17;
113
- static_assert (__is_trivially_relocatable(S17<int >), "");
114
- static_assert (__is_trivially_relocatable(S17<S3>), "");
146
+ static_assert (__is_trivially_relocatable(S17<int >), ""); // expected-warning{{deprecated}}
147
+ static_assert (__builtin_is_cpp_trivially_relocatable(S17<int >), "");
148
+
149
+ static_assert (__is_trivially_relocatable(S17<S3>), ""); // expected-warning{{deprecated}}
150
+ static_assert (__builtin_is_cpp_trivially_relocatable(S17<S3>), "");
151
+
115
152
116
153
namespace deletedCopyMoveConstructor {
117
154
struct __attribute__ ((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
118
155
CopyMoveDeleted (const CopyMoveDeleted &) = delete ;
119
156
CopyMoveDeleted (CopyMoveDeleted &&) = delete ;
120
157
};
121
158
#ifdef __ORBIS__
122
- static_assert (__is_trivially_relocatable(CopyMoveDeleted), "");
159
+ static_assert (__is_trivially_relocatable(CopyMoveDeleted), ""); // expected-warning{{deprecated}}
160
+ static_assert (!__builtin_is_cpp_trivially_relocatable(CopyMoveDeleted), "");
161
+
123
162
#else
124
- static_assert (!__is_trivially_relocatable(CopyMoveDeleted), "");
163
+ static_assert (!__is_trivially_relocatable(CopyMoveDeleted), ""); // expected-warning{{deprecated}}
164
+ static_assert (!__builtin_is_cpp_trivially_relocatable(CopyMoveDeleted), "");
165
+
125
166
#endif
126
167
127
168
struct __attribute__ ((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
128
169
CopyMoveDeleted a;
129
170
};
130
171
#ifdef __ORBIS__
131
- static_assert (__is_trivially_relocatable(S18), "");
172
+ static_assert (__is_trivially_relocatable(S18), ""); // expected-warning{{deprecated}}
173
+ static_assert (!__builtin_is_cpp_trivially_relocatable(S18), "");
132
174
#else
133
- static_assert (!__is_trivially_relocatable(S18), "");
175
+ static_assert (!__is_trivially_relocatable(S18), ""); // expected-warning{{deprecated}}
176
+ static_assert (!__builtin_is_cpp_trivially_relocatable(S18), "");
134
177
#endif
135
178
136
179
struct __attribute__ ((trivial_abi)) CopyDeleted {
137
180
CopyDeleted (const CopyDeleted &) = delete ;
138
181
CopyDeleted (CopyDeleted &&) = default ;
139
182
};
140
183
#if defined(_WIN64) && !defined(__MINGW32__)
141
- static_assert (!__is_trivially_relocatable(CopyDeleted), "");
184
+ static_assert (!__is_trivially_relocatable(CopyDeleted), ""); // expected-warning{{deprecated}}
185
+ static_assert (!__builtin_is_cpp_trivially_relocatable(CopyDeleted), "");
186
+
142
187
#else
143
- static_assert (__is_trivially_relocatable(CopyDeleted), "");
188
+ static_assert (__is_trivially_relocatable(CopyDeleted), ""); // expected-warning{{deprecated}}
189
+ static_assert (!__builtin_is_cpp_trivially_relocatable(CopyDeleted), "");
144
190
#endif
145
191
146
192
struct __attribute__ ((trivial_abi)) MoveDeleted {
147
193
MoveDeleted (const MoveDeleted &) = default ;
148
194
MoveDeleted (MoveDeleted &&) = delete ;
149
195
};
150
- static_assert (__is_trivially_relocatable(MoveDeleted), " " );
151
-
196
+ static_assert (__is_trivially_relocatable(MoveDeleted), " " ); // expected-warning{{deprecated}}
197
+ static_assert (!__builtin_is_cpp_trivially_relocatable(MoveDeleted), " " );
152
198
struct __attribute__ ((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
153
199
CopyDeleted a;
154
200
MoveDeleted b;
155
201
};
156
202
#ifdef __ORBIS__
157
- static_assert (__is_trivially_relocatable(S19), "");
203
+ static_assert (__is_trivially_relocatable(S19), ""); // expected-warning{{deprecated}}
204
+ static_assert (!__builtin_is_cpp_trivially_relocatable(S19), "");
158
205
#else
159
- static_assert (!__is_trivially_relocatable(S19), "");
206
+ static_assert (!__is_trivially_relocatable(S19), ""); // expected-warning{{deprecated}}
207
+ static_assert (!__builtin_is_cpp_trivially_relocatable(S19), "");
160
208
#endif
161
209
162
210
// This is fine since the move constructor isn't deleted.
163
211
struct __attribute__ ((trivial_abi)) S20 {
164
212
int &&a; // a member of rvalue reference type deletes the copy constructor.
165
213
};
166
214
#if defined(_WIN64) && !defined(__MINGW32__)
167
- static_assert (!__is_trivially_relocatable(S20), "");
215
+ static_assert (!__is_trivially_relocatable(S20), ""); // expected-warning{{deprecated}}
216
+ static_assert (!__builtin_is_cpp_trivially_relocatable(S20), "");
217
+
168
218
#else
169
- static_assert (__is_trivially_relocatable(S20), "");
219
+ static_assert (__is_trivially_relocatable(S20), ""); // expected-warning{{deprecated}}
220
+ static_assert (!__builtin_is_cpp_trivially_relocatable(S20), "");
221
+
170
222
#endif
171
223
} // namespace deletedCopyMoveConstructor
0 commit comments