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