Debian Codegraph @

libcxx/test/std/utilities/format/format.tuple/format.functions.format.verify.cpp

raw
1 //===----------------------------------------------------------------------===//
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 //
6 //===----------------------------------------------------------------------===//
7
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
9
10 // TODO FMT This test should not require std::to_chars(floating-point)
11 // XFAIL: availability-fp_to_chars-missing
12
13 #include <format>
14
15 #include <utility>
16 #include <tuple>
17
18 #include "test_macros.h"
19
20 // clang-format off
21
22 void f() {
23 TEST_IGNORE_NODISCARD std::format("{::}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
24 // expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
25
26 TEST_IGNORE_NODISCARD std::format("{::^}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
27 // expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
28
29 TEST_IGNORE_NODISCARD std::format("{:+}", std::make_pair(0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
30 // expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
31
32 TEST_IGNORE_NODISCARD std::format("{:m}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
33 // expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
34
35 TEST_IGNORE_NODISCARD std::format("{:m}", std::make_tuple(0, 0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
36 // expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
37 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
38 TEST_IGNORE_NODISCARD std::format(L"{::}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
39 // expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
40
41 TEST_IGNORE_NODISCARD std::format(L"{::^}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
42 // expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
43
44 TEST_IGNORE_NODISCARD std::format(L"{:+}", std::make_pair(0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
45 // expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
46
47 TEST_IGNORE_NODISCARD std::format(L"{:m}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
48 // expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
49
50 TEST_IGNORE_NODISCARD std::format(L"{:m}", std::make_tuple(0, 0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
51 // expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
52 #endif
53 }