forked from OSchip/llvm-project
[libc++][format] Allows width arg-id with value 0.
Implements: - LWG3721 Allow an arg-id with a value of zero for width in std-format-spec Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D130649
This commit is contained in:
parent
87dd8c7289
commit
36e0e2c485
|
@ -183,7 +183,7 @@
|
||||||
"`3713 <https://wg21.link/LWG3713>`__","Sorted with respect to comparator (only)","July 2022","",""
|
"`3713 <https://wg21.link/LWG3713>`__","Sorted with respect to comparator (only)","July 2022","",""
|
||||||
"`3715 <https://wg21.link/LWG3715>`__","``view_interface::empty`` is overconstrained","July 2022","",""
|
"`3715 <https://wg21.link/LWG3715>`__","``view_interface::empty`` is overconstrained","July 2022","",""
|
||||||
"`3719 <https://wg21.link/LWG3719>`__","Directory iterators should be usable with default sentinel","July 2022","",""
|
"`3719 <https://wg21.link/LWG3719>`__","Directory iterators should be usable with default sentinel","July 2022","",""
|
||||||
"`3721 <https://wg21.link/LWG3721>`__","Allow an ``arg-id`` with a value of zero for ``width`` in ``std-format-spec``","July 2022","","","|format|"
|
"`3721 <https://wg21.link/LWG3721>`__","Allow an ``arg-id`` with a value of zero for ``width`` in ``std-format-spec``","July 2022","|Complete|","16.0","|format|"
|
||||||
"`3724 <https://wg21.link/LWG3724>`__","``decay-copy`` should be constrained","July 2022","|Complete|","14.0"
|
"`3724 <https://wg21.link/LWG3724>`__","``decay-copy`` should be constrained","July 2022","|Complete|","14.0"
|
||||||
"","","","",""
|
"","","","",""
|
||||||
"`3645 <https://wg21.link/LWG3645>`__","``resize_and_overwrite`` is overspecified to call its callback with lvalues","Not voted in","|Complete|","14.0",""
|
"`3645 <https://wg21.link/LWG3645>`__","``resize_and_overwrite`` is overspecified to call its callback with lvalues","Not voted in","|Complete|","14.0",""
|
||||||
|
|
Can't render this file because it has a wrong number of fields in line 2.
|
|
@ -534,10 +534,7 @@ private:
|
||||||
if (!__width_as_arg_)
|
if (!__width_as_arg_)
|
||||||
return __width_;
|
return __width_;
|
||||||
|
|
||||||
int32_t __result = __format_spec::__substitute_arg_id(__ctx.arg(__width_));
|
return __format_spec::__substitute_arg_id(__ctx.arg(__width_));
|
||||||
if (__result == 0)
|
|
||||||
__throw_format_error("A format-spec width field replacement should have a positive value");
|
|
||||||
return __result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_LIBCPP_HIDE_FROM_ABI
|
_LIBCPP_HIDE_FROM_ABI
|
||||||
|
|
|
@ -241,6 +241,9 @@ void format_test_string(const W& world, const U& universe, TestFunction check, E
|
||||||
check_exception("A format-spec width field shouldn't have a leading zero", SV("hello {:0}"), world);
|
check_exception("A format-spec width field shouldn't have a leading zero", SV("hello {:0}"), world);
|
||||||
|
|
||||||
// *** width ***
|
// *** width ***
|
||||||
|
// Width 0 allowed, but not useful for string arguments.
|
||||||
|
check.template operator()<"hello {:{}}">(SV("hello world"), world, 0);
|
||||||
|
|
||||||
#ifdef _LIBCPP_VERSION
|
#ifdef _LIBCPP_VERSION
|
||||||
// This limit isn't specified in the Standard.
|
// This limit isn't specified in the Standard.
|
||||||
static_assert(std::__format::__number_max == 2'147'483'647, "Update the assert and the test.");
|
static_assert(std::__format::__number_max == 2'147'483'647, "Update the assert and the test.");
|
||||||
|
@ -249,7 +252,6 @@ void format_test_string(const W& world, const U& universe, TestFunction check, E
|
||||||
check_exception("The numeric value of the format-spec is too large", SV("{:10000000000}"), world);
|
check_exception("The numeric value of the format-spec is too large", SV("{:10000000000}"), world);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
check_exception("A format-spec width field replacement should have a positive value", SV("hello {:{}}"), world, 0);
|
|
||||||
check_exception("A format-spec arg-id replacement shouldn't have a negative value", SV("hello {:{}}"), world, -1);
|
check_exception("A format-spec arg-id replacement shouldn't have a negative value", SV("hello {:{}}"), world, -1);
|
||||||
check_exception("A format-spec arg-id replacement exceeds the maximum supported value", SV("hello {:{}}"), world,
|
check_exception("A format-spec arg-id replacement exceeds the maximum supported value", SV("hello {:{}}"), world,
|
||||||
unsigned(-1));
|
unsigned(-1));
|
||||||
|
|
Loading…
Reference in New Issue