From c65725eccbabf3b9b5965f27fff2d3b9f6c75930 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 15 May 2025 11:01:05 +0100 Subject: libstdc++: Fix std::format_kind primary template for Clang [PR120190] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Although Clang trunk has been adjusted to handle our std::format_kind definition (because they need to be able to compile the GCC 15.1.0 release), it's probably better to not rely on something that they might start diagnosing again in future. Define the primary template in terms of an immediately invoked function expression, so that we can put a static_assert(false) in the body. libstdc++-v3/ChangeLog: PR libstdc++/120190 * include/std/format (format_kind): Adjust primary template to not depend on itself. * testsuite/std/format/ranges/format_kind_neg.cc: Adjust expected errors. Check more invalid specializations. Reviewed-by: Tomasz Kamiński Reviewed-by: Daniel Krügler --- .../testsuite/std/format/ranges/format_kind_neg.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'libstdc++-v3/testsuite/std') diff --git a/libstdc++-v3/testsuite/std/format/ranges/format_kind_neg.cc b/libstdc++-v3/testsuite/std/format/ranges/format_kind_neg.cc index bf8619d..0d761ae 100644 --- a/libstdc++-v3/testsuite/std/format/ranges/format_kind_neg.cc +++ b/libstdc++-v3/testsuite/std/format/ranges/format_kind_neg.cc @@ -5,9 +5,14 @@ #include -template struct Tester { }; +void test() +{ + (void) std::format_kind; // { dg-error "here" } + (void) std::format_kind; // { dg-error "here" } + (void) std::format_kind; // { dg-error "here" } + (void) std::format_kind; // { dg-error "here" } + (void) std::format_kind; // { dg-error "here" } + (void) std::format_kind; // { dg-error "here" } +} -Tester> t; // { dg-error "here" } - -// { dg-error "use of 'std::format_kind" "" { target *-*-* } 0 } -// { dg-error "primary_template_not_defined" "" { target *-*-* } 0 } +// { dg-error "cannot use primary template of 'std::format_kind'" "" { target *-*-* } 0 } -- cgit v1.1