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