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

source code of libcxx/test/std/utilities/format/format.tuple/format.functions.format.verify.cpp