| 1 |
// { dg-do compile { target c++26 } } |
| 2 |
// { dg-skip-if "" { *-*-* } { "-fno-char8_t" } } |
| 3 |
|
| 4 |
#include <format> |
| 5 |
|
| 6 |
void |
| 7 |
test_invalid() |
| 8 |
{ |
| 9 |
std::format_parse_context pc(""); |
| 10 |
|
| 11 |
// These types are all valid: |
| 12 |
pc.check_dynamic_spec<bool, char, int, unsigned, long long, |
| 13 |
unsigned long long, float, double, long double, |
| 14 |
const char*, std::string_view, const void*>(0); |
| 15 |
|
| 16 |
// LWG 4142. check_dynamic_spec should require at least one type |
| 17 |
pc.check_dynamic_spec<>(0); // { dg-error "here" } |
| 18 |
|
| 19 |
pc.check_dynamic_spec<void>(0); // { dg-error "here" } |
| 20 |
// const void* is allowed, but void* is not |
| 21 |
pc.check_dynamic_spec<void*>(0); // { dg-error "here" } |
| 22 |
// int and long long are allowed, but long is not |
| 23 |
pc.check_dynamic_spec<long>(0); // { dg-error "here" } |
| 24 |
// char_type is allowed, but other character types are not |
| 25 |
pc.check_dynamic_spec<wchar_t>(0); // { dg-error "here" } |
| 26 |
pc.check_dynamic_spec<char8_t>(0); // { dg-error "here" } |
| 27 |
// std::string_view is allowed, but std::string is not |
| 28 |
pc.check_dynamic_spec<std::string>(0); // { dg-error "here" } |
| 29 |
// The types in the pack must be unique. |
| 30 |
pc.check_dynamic_spec<int, bool, int>(0); // { dg-error "here" } |
| 31 |
|
| 32 |
std::wformat_parse_context wpc(L""); |
| 33 |
wpc.check_dynamic_spec<bool, wchar_t, int, unsigned, long long, |
| 34 |
unsigned long long, float, double, long double, |
| 35 |
const wchar_t*, std::wstring_view, const void*>(0); |
| 36 |
wpc.check_dynamic_spec<char>(0); // { dg-error "here" } |
| 37 |
wpc.check_dynamic_spec<char16_t>(0); // { dg-error "here" } |
| 38 |
wpc.check_dynamic_spec<char32_t>(0); // { dg-error "here" } |
| 39 |
} |
| 40 |
|
| 41 |
// Each failure above will trigger this static_assert: |
| 42 |
// { dg-error "allowed types" "" { target *-*-* } 0 } |