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