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
6 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10 // TODO FMT This test should not require std::to_chars(floating-point)
11 // XFAIL: availability-fp_to_chars-missing
18 #include "test_macros.h"
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}}
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}}
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}}
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}}
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}}
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}}
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}}
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}}
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}}