@@ -179,18 +179,20 @@ static_assert(false, Message{}); // expected-error {{static assertion failed: He
179
179
}
180
180
181
181
struct MessageInvalidSize {
182
- constexpr auto size (int ) const ; // expected-note {{candidate function not viable: requires 1 argument, but 0 were provided }}
183
- constexpr auto data () const ;
182
+ constexpr unsigned long size (int ) const ; // expected-note {{'size' declared here }}
183
+ constexpr const char * data () const ;
184
184
};
185
185
struct MessageInvalidData {
186
- constexpr auto size () const ;
187
- constexpr auto data (int ) const ; // expected-note {{candidate function not viable: requires 1 argument, but 0 were provided }}
186
+ constexpr unsigned long size () const ;
187
+ constexpr const char * data (int ) const ; // expected-note {{'data' declared here }}
188
188
};
189
189
190
190
static_assert (false , MessageInvalidSize{}); // expected-error {{static assertion failed}} \
191
- // expected-error {{the message in a static assertion must have a 'size()' member function returning an object convertible to 'std::size_t'}}
191
+ // expected-error {{the message in a static assertion must have a 'size()' member function returning an object convertible to 'std::size_t'}} \
192
+ // expected-error {{too few arguments to function call, expected 1, have 0}}
192
193
static_assert (false , MessageInvalidData{}); // expected-error {{static assertion failed}} \
193
- // expected-error {{the message in a static assertion must have a 'data()' member function returning an object convertible to 'const char *'}}
194
+ // expected-error {{the message in a static assertion must have a 'data()' member function returning an object convertible to 'const char *'}} \
195
+ // expected-error {{too few arguments to function call, expected 1, have 0}}
194
196
195
197
struct NonConstMembers {
196
198
constexpr int size () {
@@ -227,14 +229,14 @@ static_assert(false, Variadic{}); // expected-error {{static assertion failed: O
227
229
228
230
template <typename T>
229
231
struct DeleteAndRequires {
230
- constexpr int size () = delete; // expected-note {{candidate function has been explicitly deleted}}
231
- constexpr const char * data () requires false; // expected-note {{candidate function not viable: constraints not satisfied}} \
232
- // expected-note {{because 'false' evaluated to false}}
232
+ constexpr int size () = delete; // expected-note {{'size' has been explicitly marked deleted here}}
233
+ constexpr const char * data () requires false; // expected-note {{because 'false' evaluated to false}}
233
234
};
234
235
static_assert (false , DeleteAndRequires<void >{});
235
236
// expected-error@-1 {{static assertion failed}} \
236
237
// expected-error@-1 {{the message in a static assertion must have a 'size()' member function returning an object convertible to 'std::size_t'}}\
237
- // expected-error@-1 {{the message in a static assertion must have a 'data()' member function returning an object convertible to 'const char *'}}
238
+ // expected-error@-1 {{invalid reference to function 'data': constraints not satisfied}} \
239
+ // expected-error@-1 {{attempt to use a deleted function}}
238
240
239
241
class Private {
240
242
constexpr int size (int i = 0 ) { // expected-note {{implicitly declared private here}}
@@ -294,6 +296,9 @@ struct Frobble {
294
296
constexpr const char *data () const { return " hello" ; }
295
297
};
296
298
299
+ constexpr Frobble operator " " _myd (const char *, unsigned long ) { return Frobble{}; }
300
+ static_assert (false , " foo" _myd); // expected-error {{static assertion failed: hello}}
301
+
297
302
Good<Frobble> a; // expected-note {{in instantiation}}
298
303
Bad<int > b; // expected-note {{in instantiation}}
299
304
@@ -307,3 +312,32 @@ static_assert((char8_t)-128 == (char8_t)-123, ""); // expected-error {{failed}}
307
312
static_assert ((char16_t )0xFEFF == (char16_t )0xDB93 , " " ); // expected-error {{failed}} \
308
313
// expected-note {{evaluates to 'u'' (0xFEFF, 65279) == u'\xDB93' (0xDB93, 56211)'}}
309
314
}
315
+
316
+ struct Static {
317
+ static constexpr int size () { return 5 ; }
318
+ static constexpr const char *data () { return " hello" ; }
319
+ };
320
+ static_assert (false , Static{}); // expected-error {{static assertion failed: hello}}
321
+
322
+ struct Data {
323
+ unsigned long size = 0 ;
324
+ const char * data = " hello" ;
325
+ };
326
+ static_assert (false , Data{}); // expected-error {{called object type 'unsigned long' is not a function or function pointer}} \
327
+ // expected-error {{called object type 'const char *' is not a function or function pointer}} \
328
+ // expected-error {{the message in a static assertion must have a 'size()' member function returning an object convertible to 'std::size_t'}} \
329
+ // expected-error {{static assertion failed}}
330
+
331
+ struct Callable {
332
+ struct {
333
+ constexpr auto operator ()() const {
334
+ return 5 ;
335
+ };
336
+ } size;
337
+ struct {
338
+ constexpr auto operator ()() const {
339
+ return " hello" ;
340
+ };
341
+ } data;
342
+ };
343
+ static_assert (false , Callable{}); // expected-error {{static assertion failed: hello}}
0 commit comments