Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<chrono> Formatting: C++20's Final Boss #1870

Merged
merged 41 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2118d1e
Squashed chronat changes.
StephanTLavavej Apr 15, 2021
33e3804
Fix tests.
StephanTLavavej Apr 15, 2021
cdfa88c
charT -> char mod/type, small bugfix and nits
eldakesh-ms Apr 15, 2021
0aeb5ea
chronat: Add year and year_month_day formatting (#1840)
eldakesh-ms Apr 15, 2021
206727e
Add hh_mm_ss operator<<
eldakesh-ms Apr 15, 2021
1cb654b
Fix tests
eldakesh-ms Apr 15, 2021
e7b705a
ymd has info for weekday too
mnatsuhara Apr 15, 2021
5505ea3
add test for u w
mnatsuhara Apr 15, 2021
4c236a3
Various cleanups. (#1842)
StephanTLavavej Apr 16, 2021
5bf0c50
Modifier table update
eldakesh-ms Apr 16, 2021
1187292
Update the modifier table, use uint8_t.
StephanTLavavej Apr 16, 2021
838cd1f
Robuster OOB handling
eldakesh-ms Apr 16, 2021
3a19af7
Add general time filler
eldakesh-ms Apr 16, 2021
889fe20
Remove failed type checks
eldakesh-ms Apr 16, 2021
7ee91b1
Add/centralize formatters, replace operators.
StephanTLavavej Apr 16, 2021
48eb7f8
Update libcxx skips.
StephanTLavavej Apr 16, 2021
84760ea
Add hh_mm_ss formatter
eldakesh-ms Apr 16, 2021
29b7094
Add month_day, month_day_last, and year_month formatting
eldakesh-ms Apr 16, 2021
f6ba00d
Expand functionality of _Try_simple_write into _Custom_write
eldakesh-ms Apr 16, 2021
0814ca2
chronat: Allow day from month_day_last conditionally (#1845)
eldakesh-ms Apr 16, 2021
a0f6558
chronat: Clock formatting (#1846)
eldakesh-ms Apr 16, 2021
d418366
wd, wdi formatting (#1847)
mnatsuhara Apr 17, 2021
8aeda0c
Only throw on hh_mm_ss if the hour field is used and is OOB
eldakesh-ms Apr 16, 2021
6c06f23
`<chrono>` formatting: fix UB, various cleanups (#1848)
StephanTLavavej Apr 17, 2021
d718499
`<chrono>`: Implement exception class constructors (#1849)
StephanTLavavej Apr 17, 2021
d705b61
`<chrono>` formatting: `weekday_last`, `month_weekday`, `month_weekda…
StephanTLavavej Apr 18, 2021
1f874eb
`<chrono>` formatting: More cleanups (#1857)
StephanTLavavej Apr 18, 2021
c06416c
`<chrono>` formatting: Simplify test (#1859)
StephanTLavavej Apr 19, 2021
229dfde
chronat: Add duration formatter (#1861)
eldakesh-ms Apr 19, 2021
39c722f
`<chrono>` formatting: `sys_info`, `local_info`, feature-test macro (…
StephanTLavavej Apr 20, 2021
d69d7ba
Add local_time_format() and zoned_time. (#1863)
StephanTLavavej Apr 20, 2021
65ad8a7
<chrono>: Add %j support and expand %aAuw (#1864)
eldakesh-ms Apr 20, 2021
d488200
<chrono: Rewrite %r spec for C locale (#1865)
eldakesh-ms Apr 20, 2021
cc2651d
<chrono>: Fix hh_mm_ss subsecond formatting for floats (#1866)
eldakesh-ms Apr 20, 2021
cec735c
<chrono>: Fix utc_clock seconds formatting (#1868)
eldakesh-ms Apr 21, 2021
e015c35
`<chrono>` formatting: extend `%r`, add `%g %G %U %V %W` (#1869)
StephanTLavavej Apr 21, 2021
d652eab
<chrono>: Fine grained bounds checking (#1871)
eldakesh-ms Apr 21, 2021
360e631
Fixes two-digit year for negative centuries. (#1872)
MattStephanson Apr 21, 2021
bd5b397
Use run_tz_test to catch exceptions and handle internal machines.
StephanTLavavej Apr 21, 2021
7c177d0
Validate year_month::ok() for %g %G.
StephanTLavavej Apr 22, 2021
ab1001c
We don't need _No_chrono_specs.
StephanTLavavej Apr 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,456 changes: 1,316 additions & 140 deletions stl/inc/chrono

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions stl/inc/format
Original file line number Diff line number Diff line change
Expand Up @@ -1598,9 +1598,9 @@ _NODISCARD _OutputIt _Fmt_write(_OutputIt _Out, const basic_string_view<_CharT>
return _RANGES copy(_Value, _STD move(_Out)).out;
}

template <class _CharT, class _OutputIt, class _Func>
_NODISCARD _OutputIt _Write_aligned(_OutputIt _Out, const int _Width, const _Basic_format_specs<_CharT>& _Specs,
const _Fmt_align _Default_align, _Func&& _Fn) {
template <class _OutputIt, class _Specs_type, class _Func>
_NODISCARD _OutputIt _Write_aligned(
_OutputIt _Out, const int _Width, const _Specs_type& _Specs, const _Fmt_align _Default_align, _Func&& _Fn) {
int _Fill_left = 0;
int _Fill_right = 0;
auto _Alignment = _Specs._Alignment;
Expand All @@ -1627,7 +1627,7 @@ _NODISCARD _OutputIt _Write_aligned(_OutputIt _Out, const int _Width, const _Bas
}
}

const basic_string_view<_CharT> _Fill_char{_Specs._Fill, _Specs._Fill_length};
const basic_string_view _Fill_char{_Specs._Fill, _Specs._Fill_length};
for (; _Fill_left > 0; --_Fill_left) {
_Out = _RANGES copy(_Fill_char, _STD move(_Out)).out;
}
Expand Down
15 changes: 8 additions & 7 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
// P0325R4 to_array()
// P0339R6 polymorphic_allocator<>
// P0355R7 <chrono> Calendars And Time Zones
// (partially implemented)
// P0356R5 bind_front()
// P0357R3 Supporting Incomplete Types In reference_wrapper
// P0408R7 Efficient Access To basic_stringbuf's Buffer
Expand Down Expand Up @@ -1172,12 +1171,6 @@
#define __cpp_lib_variant 201606L
#endif // _HAS_CXX17

#if _HAS_CXX17
#define __cpp_lib_chrono 201611L // P0505R0 constexpr For <chrono> (Again)
#else // _HAS_CXX17
#define __cpp_lib_chrono 201510L // P0092R1 <chrono> floor(), ceil(), round(), abs()
#endif // _HAS_CXX17

// C++20
#define __cpp_lib_atomic_value_initialization 201911L

Expand Down Expand Up @@ -1303,6 +1296,14 @@
#define __cpp_lib_array_constexpr 201803L
#endif // _HAS_CXX17

#if _HAS_CXX20 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
#define __cpp_lib_chrono 201907L // P1466R3 Miscellaneous Minor Fixes For <chrono>
#elif _HAS_CXX17
#define __cpp_lib_chrono 201611L // P0505R0 constexpr For <chrono> (Again)
#else // _HAS_CXX17
#define __cpp_lib_chrono 201510L // P0092R1 <chrono> floor(), ceil(), round(), abs()
#endif // _HAS_CXX17

#if _HAS_CXX20
#define __cpp_lib_shared_ptr_arrays 201707L // P0674R1 make_shared() For Arrays
#else // _HAS_CXX20
Expand Down
89 changes: 51 additions & 38 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,43 +275,6 @@ std/utilities/memory/default.allocator/allocator.members/allocate.verify.cpp SKI


# *** MISSING STL FEATURES ***
# C++20 P0355R7 "<chrono> Calendars And Time Zones"
std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.md/time.cal.md.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.mdlast/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.year/time.cal.year.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.ym/time.cal.ym.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.ymdlast/time.cal.ymdlast.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.ymwd/time.cal.ymwd.nonmembers/streaming.pass.cpp FAIL
std/utilities/time/time.cal/time.cal.ymwdlast/time.cal.ymwdlast.nonmembers/streaming.pass.cpp FAIL

# C++20 P0466R5 "Layout-Compatibility And Pointer-Interconvertibility Traits"
std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp:1 FAIL

# C++20 P0608R3 "Improving variant's Converting Constructor/Assignment"
std/utilities/variant/variant.variant/variant.assign/conv.pass.cpp FAIL
std/utilities/variant/variant.variant/variant.assign/T.pass.cpp FAIL
std/utilities/variant/variant.variant/variant.ctor/conv.pass.cpp FAIL
std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp FAIL

# C++20 P0784R7 "More constexpr containers"
std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp FAIL
std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp FAIL
std/utilities/memory/specialized.algorithms/specialized.construct/construct_at.pass.cpp FAIL

# C++20 P0896R4 "<ranges>"
std/language.support/support.limits/support.limits.general/algorithm.version.pass.cpp FAIL
std/language.support/support.limits/support.limits.general/functional.version.pass.cpp FAIL
std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp FAIL
std/language.support/support.limits/support.limits.general/memory.version.pass.cpp FAIL

# C++23 P1048R1 "is_scoped_enum"
std/utilities/meta/meta.unary/meta.unary.prop/is_scoped_enum.pass.cpp FAIL

Expand Down Expand Up @@ -662,6 +625,28 @@ std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.
std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp FAIL
std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp FAIL

# Bogus test uses std::cout without including <iostream>.
std/utilities/time/time.cal/time.cal.wdidx/time.cal.wdidx.nonmembers/streaming.pass.cpp FAIL

# Bogus test constructs year_month_weekday from weekday, but the constructor actually takes weekday_indexed.
std/utilities/time/time.cal/time.cal.ymwd/time.cal.ymwd.nonmembers/streaming.pass.cpp FAIL

# We define __cpp_lib_has_unique_object_representations in C++17 mode; test error says it
# "should not be defined when TEST_HAS_BUILTIN_IDENTIFIER(__has_unique_object_representations) || TEST_GCC_VER >= 700 is not defined!"
std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp:1 FAIL
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved

# Tests expect __cpp_lib_ranges to have the old value 201811L for P0896R4; we define the C++20 value 201911L for P1716R3.
std/language.support/support.limits/support.limits.general/algorithm.version.pass.cpp FAIL
std/language.support/support.limits/support.limits.general/functional.version.pass.cpp FAIL
std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp FAIL

# Test expects __cpp_lib_chrono to have the old value 201611L for P0505R0; we define the C++20 value 201907L for P1466R3.
std/language.support/support.limits/support.limits.general/chrono.version.pass.cpp FAIL

# We unconditionally define __cpp_lib_addressof_constexpr; test error says it
# "should not be defined when TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 is not defined!"
std/language.support/support.limits/support.limits.general/memory.version.pass.cpp FAIL
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved


# *** LIKELY STL BUGS ***
# Not yet analyzed, likely STL bugs. Assertions and other runtime failures.
Expand Down Expand Up @@ -868,9 +853,22 @@ std/re/re.alg/re.alg.search/basic.locale.pass.cpp FAIL
std/re/re.alg/re.alg.search/ecma.locale.pass.cpp FAIL
std/re/re.alg/re.alg.search/extended.locale.pass.cpp FAIL

# Not yet analyzed. Various static_asserts.
std/utilities/variant/variant.variant/variant.assign/conv.pass.cpp FAIL
std/utilities/variant/variant.variant/variant.assign/T.pass.cpp FAIL
std/utilities/variant/variant.variant/variant.ctor/conv.pass.cpp FAIL
std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp FAIL

# Not yet analyzed. Involves incomplete types.
std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp FAIL
std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp FAIL

# Not yet analyzed. Error mentions allocator<const T>.
std/utilities/memory/specialized.algorithms/specialized.construct/construct_at.pass.cpp FAIL


# *** XFAILs WHICH PASS ***
# Not yet implemented in libcxx and marked as XFAIL
# Not yet implemented in libcxx and marked as "XFAIL: libc++"
std/strings/c.strings/cuchar.pass.cpp PASS
std/utilities/function.objects/func.search/func.search.bm/default.pass.cpp PASS
std/utilities/function.objects/func.search/func.search.bm/hash.pass.cpp PASS
Expand All @@ -880,3 +878,18 @@ std/utilities/function.objects/func.search/func.search.bmh/default.pass.cpp PASS
std/utilities/function.objects/func.search/func.search.bmh/hash.pass.cpp PASS
std/utilities/function.objects/func.search/func.search.bmh/hash.pred.pass.cpp PASS
std/utilities/function.objects/func.search/func.search.bmh/pred.pass.cpp PASS

# Not yet implemented in libcxx and marked as "XFAIL: *"
std/utilities/time/time.cal/time.cal.day/time.cal.day.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.md/time.cal.md.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.mdlast/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.month/time.cal.month.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.mwd/time.cal.mwd.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.wdlast/time.cal.wdlast.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.weekday/time.cal.weekday.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.year/time.cal.year.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.ym/time.cal.ym.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.ymd/time.cal.ymd.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.ymdlast/time.cal.ymdlast.nonmembers/streaming.pass.cpp SKIPPED
std/utilities/time/time.cal/time.cal.ymwdlast/time.cal.ymwdlast.nonmembers/streaming.pass.cpp SKIPPED
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved
72 changes: 35 additions & 37 deletions tests/libcxx/skipped_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -275,43 +275,6 @@ utilities\memory\default.allocator\allocator.members\allocate.verify.cpp


# *** MISSING STL FEATURES ***
# C++20 P0355R7 "<chrono> Calendars And Time Zones"
utilities\time\time.cal\time.cal.day\time.cal.day.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.md\time.cal.md.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.mdlast\streaming.pass.cpp
utilities\time\time.cal\time.cal.month\time.cal.month.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.mwd\time.cal.mwd.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.mwdlast\time.cal.mwdlast.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.wdidx\time.cal.wdidx.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.wdlast\time.cal.wdlast.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.weekday\time.cal.weekday.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.year\time.cal.year.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.ym\time.cal.ym.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.ymd\time.cal.ymd.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.ymdlast\time.cal.ymdlast.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.ymwd\time.cal.ymwd.nonmembers\streaming.pass.cpp
utilities\time\time.cal\time.cal.ymwdlast\time.cal.ymwdlast.nonmembers\streaming.pass.cpp

# C++20 P0466R5 "Layout-Compatibility And Pointer-Interconvertibility Traits"
language.support\support.limits\support.limits.general\type_traits.version.pass.cpp

# C++20 P0608R3 "Improving variant's Converting Constructor/Assignment"
utilities\variant\variant.variant\variant.assign\conv.pass.cpp
utilities\variant\variant.variant\variant.assign\T.pass.cpp
utilities\variant\variant.variant\variant.ctor\conv.pass.cpp
utilities\variant\variant.variant\variant.ctor\T.pass.cpp

# C++20 P0784R7 "More constexpr containers"
utilities\memory\allocator.traits\allocator.traits.members\construct.pass.cpp
utilities\memory\allocator.traits\allocator.traits.members\destroy.pass.cpp
utilities\memory\specialized.algorithms\specialized.construct\construct_at.pass.cpp

# C++20 P0896R4 "<ranges>"
language.support\support.limits\support.limits.general\algorithm.version.pass.cpp
language.support\support.limits\support.limits.general\functional.version.pass.cpp
language.support\support.limits\support.limits.general\iterator.version.pass.cpp
language.support\support.limits\support.limits.general\memory.version.pass.cpp

# C++23 P1048R1 "is_scoped_enum"
utilities\meta\meta.unary\meta.unary.prop\is_scoped_enum.pass.cpp

Expand Down Expand Up @@ -662,6 +625,28 @@ utilities\allocator.adaptor\allocator.adaptor.members\construct_pair_rvalue.pass
utilities\allocator.adaptor\allocator.adaptor.members\construct_pair_values.pass.cpp
utilities\allocator.adaptor\allocator.adaptor.members\construct_type.pass.cpp

# Bogus test uses std::cout without including <iostream>.
utilities\time\time.cal\time.cal.wdidx\time.cal.wdidx.nonmembers\streaming.pass.cpp

# Bogus test constructs year_month_weekday from weekday, but the constructor actually takes weekday_indexed.
utilities\time\time.cal\time.cal.ymwd\time.cal.ymwd.nonmembers\streaming.pass.cpp

# We define __cpp_lib_has_unique_object_representations in C++17 mode; test error says it
# "should not be defined when TEST_HAS_BUILTIN_IDENTIFIER(__has_unique_object_representations) || TEST_GCC_VER >= 700 is not defined!"
language.support\support.limits\support.limits.general\type_traits.version.pass.cpp

# Tests expect __cpp_lib_ranges to have the old value 201811L for P0896R4; we define the C++20 value 201911L for P1716R3.
language.support\support.limits\support.limits.general\algorithm.version.pass.cpp
language.support\support.limits\support.limits.general\functional.version.pass.cpp
language.support\support.limits\support.limits.general\iterator.version.pass.cpp

# Test expects __cpp_lib_chrono to have the old value 201611L for P0505R0; we define the C++20 value 201907L for P1466R3.
language.support\support.limits\support.limits.general\chrono.version.pass.cpp

# We unconditionally define __cpp_lib_addressof_constexpr; test error says it
# "should not be defined when TEST_HAS_BUILTIN(__builtin_addressof) || TEST_GCC_VER >= 700 is not defined!"
language.support\support.limits\support.limits.general\memory.version.pass.cpp


# *** LIKELY STL BUGS ***
# Not yet analyzed, likely STL bugs. Assertions and other runtime failures.
Expand Down Expand Up @@ -868,6 +853,19 @@ re\re.alg\re.alg.search\basic.locale.pass.cpp
re\re.alg\re.alg.search\ecma.locale.pass.cpp
re\re.alg\re.alg.search\extended.locale.pass.cpp

# Not yet analyzed. Various static_asserts.
utilities\variant\variant.variant\variant.assign\conv.pass.cpp
utilities\variant\variant.variant\variant.assign\T.pass.cpp
utilities\variant\variant.variant\variant.ctor\conv.pass.cpp
utilities\variant\variant.variant\variant.ctor\T.pass.cpp

# Not yet analyzed. Involves incomplete types.
utilities\memory\allocator.traits\allocator.traits.members\construct.pass.cpp
utilities\memory\allocator.traits\allocator.traits.members\destroy.pass.cpp

# Not yet analyzed. Error mentions allocator<const T>.
utilities\memory\specialized.algorithms\specialized.construct\construct_at.pass.cpp


# *** SKIPPED FOR MSVC-INTERNAL CONTEST ONLY ***
# Our machinery doesn't understand compile-only `.compile.pass.cpp` tests.
Expand Down
Loading