static _Element_t
_S_make_elt(_Tp& __v)
{
+ using _Tq = remove_const_t<_Tp>;
+ using _CharT = typename _Context::char_type;
+ static_assert(is_default_constructible_v<formatter<_Tq, _CharT>>,
+ "std::formatter must be specialized for the type "
+ "of each format arg");
+ using __format::__formattable_with;
+ if constexpr (is_const_v<_Tp>)
+ if constexpr (!__formattable_with<_Tp, _Context>)
+ if constexpr (__formattable_with<_Tq, _Context>)
+ static_assert(__formattable_with<_Tp, _Context>,
+ "format arg must be non-const because its "
+ "std::formatter specialization has a "
+ "non-const reference parameter");
basic_format_arg<_Context> __arg(__v);
if constexpr (_S_values_only)
return __arg._M_val;
regsub -all "(^|\n)\[^\n\]*: . skipping \[0-9\]* instantiation contexts \[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*: in .constexpr. expansion \[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*: in requirements .with\[^\n\]*" $text "" text
+ regsub -all "(^|\n)\[^\n\]*: in requirements with\[^\n\]*" $text "" text
regsub -all "(^|\n) inlined from \[^\n\]*" $text "" text
# Why doesn't GCC need these to strip header context?
regsub -all "(^|\n)In file included from \[^\n\]*" $text "" text
std::string rval() { return "path/etic/experience"; }
-void f()
+void test_rval()
{
(void)std::make_format_args(rval()); // { dg-error "cannot bind non-const lvalue reference" }
}
+
+void test_missing_specialization()
+{
+ struct X { };
+ X x;
+ (void)std::make_format_args(x); // { dg-error "here" }
+// { dg-error "std::formatter must be specialized" "" { target *-*-* } 0 }
+}
+
+struct Y { };
+template<> class std::formatter<Y> {
+public:
+ constexpr typename format_parse_context::iterator
+ parse(format_parse_context& c)
+ { return c.begin(); }
+
+ template<class C>
+ typename C::iterator format(Y&, C&) const;
+};
+
+void test(std::formatter<Y>& f, std::format_parse_context& pc) {
+ f.parse(pc);
+}
+
+void test_const_arg()
+{
+ const Y y;
+ (void)std::make_format_args(y); // { dg-error "here" }
+// { dg-error "format arg must be non-const" "" { target *-*-* } 0 }
+}
+
+// { dg-prune-output "no matching function for call to .*::basic_format_arg<" }
auto s = std::format(" {9} "); // { dg-error "call to consteval function" }
// { dg-error "invalid.arg.id" "" { target *-*-* } 0 }
+
+struct X { };
+std::format_string<X> str(""); // dg-error "here" }
+// { dg-error "std::formatter must be specialized" "" { target *-*-* } 0 }