Skip to content

Commit 12c8a24

Browse files
committed
Fix tests
1 parent 4755e81 commit 12c8a24

30 files changed

+186
-73
lines changed

include/cpp2util.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,8 @@ constexpr auto is( X const& x ) -> auto
20272027
}
20282028

20292029

2030-
inline constexpr auto is( specialization_of_template<std::variant> auto const& x, auto&& value ) -> bool
2030+
template <specialization_of_template<std::variant> X>
2031+
inline constexpr auto is( X const& x, auto&& value ) -> bool
20312032
{
20322033
return type_find_if(x, [&]<typename It>(It const&) -> bool {
20332034
if (x.index() == It::index) {
@@ -2041,16 +2042,16 @@ inline constexpr auto is( specialization_of_template<std::variant> auto const& x
20412042
}) != std::variant_npos;
20422043
}
20432044

2044-
template< typename C >
2045-
auto as(specialization_of_template<std::variant> auto&& x CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT_AS) -> decltype(auto)
2045+
template< typename C, specialization_of_template<std::variant> X >
2046+
auto as( X&& x CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT_AS) -> decltype(auto)
20462047
{
2047-
constness_like_t<C, decltype(x)>* ptr = nullptr;
2048+
constness_like_t<C, X>* ptr = nullptr;
20482049
type_find_if(CPP2_FORWARD(x), [&]<typename It>(It const&) -> bool {
20492050
if constexpr (std::is_same_v< typename It::type, C >) { if (CPP2_FORWARD(x).index() == It::index) { ptr = &std::get<It::index>(x); return true; } };
20502051
return false;
20512052
});
20522053
if (!ptr) { Throw( std::bad_variant_access(), "'as' cast failed for 'variant'"); }
2053-
return cpp2::forward_like<decltype(x)>(*ptr);
2054+
return cpp2::forward_like<X>(*ptr);
20542055
}
20552056

20562057
//-------------------------------------------------------------------------------------------------------------
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(1068) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector<int>]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4]
1+
../../../include/cpp2util.h(1081) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector<int>]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(880) : Bounds safety violation
1+
../../../include/cpp2util.h(893) : Bounds safety violation
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(880) : Contract violation: fill: value must contain at least count elements
1+
../../../include/cpp2util.h(893) : Contract violation: fill: value must contain at least count elements
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
sending error to my framework... [dynamic null dereference attempt detected]
2-
from source location: ../../../include/cpp2util.h(959) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&]
2+
from source location: ../../../include/cpp2util.h(972) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(959) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::expected<int, bool>]: Null safety violation: std::expected has an unexpected value
1+
../../../include/cpp2util.h(972) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::expected<int, bool>]: Null safety violation: std::expected has an unexpected value
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(959) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional<int>]: Null safety violation: std::optional does not contain a value
1+
../../../include/cpp2util.h(972) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional<int>]: Null safety violation: std::optional does not contain a value
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(959) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr<int>]: Null safety violation: std::shared_ptr is empty
1+
../../../include/cpp2util.h(972) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr<int>]: Null safety violation: std::shared_ptr is empty
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(959) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr<int>]: Null safety violation: std::unique_ptr is empty
1+
../../../include/cpp2util.h(972) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr<int>]: Null safety violation: std::unique_ptr is empty

regression-tests/test-results/apple-clang-15-c++2b/pure2-range-operators.cpp.execution

+16
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,19 @@ And from indexes 1..=5 they are:
1818
Make sure non-random-access iterators work:
1919
Hokey
2020
Pokey
21+
22+
Make sure .sum works:
23+
210
24+
190
25+
26+
Make sure .contains works:
27+
false
28+
true
29+
true
30+
true
31+
false
32+
false
33+
true
34+
true
35+
false
36+
false

regression-tests/test-results/clang-15-c++20-libcpp/pure2-range-operators.cpp.execution

+16
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,19 @@ And from indexes 1..=5 they are:
1818
Make sure non-random-access iterators work:
1919
Hokey
2020
Pokey
21+
22+
Make sure .sum works:
23+
210
24+
190
25+
26+
Make sure .contains works:
27+
false
28+
true
29+
true
30+
true
31+
false
32+
false
33+
true
34+
true
35+
false
36+
false
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(1068) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector<int>]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4]
1+
../../../include/cpp2util.h(1081) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector<int>]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(880) : Bounds safety violation
1+
../../../include/cpp2util.h(893) : Bounds safety violation
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(880) : Contract violation: fill: value must contain at least count elements
1+
../../../include/cpp2util.h(893) : Contract violation: fill: value must contain at least count elements
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
sending error to my framework... [dynamic null dereference attempt detected]
2-
from source location: ../../../include/cpp2util.h(959) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&]
2+
from source location: ../../../include/cpp2util.h(972) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&]
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(959) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional<int>]: Null safety violation: std::optional does not contain a value
1+
../../../include/cpp2util.h(972) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional<int>]: Null safety violation: std::optional does not contain a value
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(959) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr<int>]: Null safety violation: std::shared_ptr is empty
1+
../../../include/cpp2util.h(972) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr<int>]: Null safety violation: std::shared_ptr is empty
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../include/cpp2util.h(959) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr<int>]: Null safety violation: std::unique_ptr is empty
1+
../../../include/cpp2util.h(972) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr<int>]: Null safety violation: std::unique_ptr is empty

regression-tests/test-results/clang-15-c++20/pure2-range-operators.cpp.execution

+16
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,19 @@ And from indexes 1..=5 they are:
1818
Make sure non-random-access iterators work:
1919
Hokey
2020
Pokey
21+
22+
Make sure .sum works:
23+
210
24+
190
25+
26+
Make sure .contains works:
27+
false
28+
true
29+
true
30+
true
31+
false
32+
false
33+
true
34+
true
35+
false
36+
false

regression-tests/test-results/clang-18-c++20/pure2-range-operators.cpp.execution

+16
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,19 @@ And from indexes 1..=5 they are:
1818
Make sure non-random-access iterators work:
1919
Hokey
2020
Pokey
21+
22+
Make sure .sum works:
23+
210
24+
190
25+
26+
Make sure .contains works:
27+
false
28+
true
29+
true
30+
true
31+
false
32+
false
33+
true
34+
true
35+
false
36+
false

regression-tests/test-results/clang-18-c++23-libcpp/pure2-range-operators.cpp.execution

+16
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,19 @@ And from indexes 1..=5 they are:
1818
Make sure non-random-access iterators work:
1919
Hokey
2020
Pokey
21+
22+
Make sure .sum works:
23+
210
24+
190
25+
26+
Make sure .contains works:
27+
false
28+
true
29+
true
30+
true
31+
false
32+
false
33+
true
34+
true
35+
false
36+
false

regression-tests/test-results/gcc-10-c++20/pure2-bugfix-for-requires-clause-in-forward-declaration.cpp.output

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:46: error: expect
66
In file included from pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:7:
77
../../../include/cpp2util.h:10005:47: error: static assertion failed: GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10.
88
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:4:1: note: in expansion of macro ‘CPP2_REQUIRES_’
9-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: no declaration matches ‘element::element(auto:94&&) requires is_same_v<std::__cxx11::string, typename std::remove_cv<typename std::remove_reference<decltype(element::__ct ::n)>::type>::type>’
9+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: no declaration matches ‘element::element(auto:95&&) requires is_same_v<std::__cxx11::string, typename std::remove_cv<typename std::remove_reference<decltype(element::__ct ::n)>::type>::type>’
1010
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:5:11: note: candidates are: ‘element::element(const element&)’
11-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:20: note: ‘template<class auto:92> element::element(auto:92&&)’
11+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:20: note: ‘template<class auto:93> element::element(auto:93&&)’
1212
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here
1313
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:5:78: error: expected unqualified-id before ‘{’ token
14-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:8: error: no declaration matches ‘element& element::operator=(auto:95&&) requires is_same_v<std::__cxx11::string, typename std::remove_cv<typename std::remove_reference<decltype(element::operator=::n)>::type>::type>’
14+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:8: error: no declaration matches ‘element& element::operator=(auto:96&&) requires is_same_v<std::__cxx11::string, typename std::remove_cv<typename std::remove_reference<decltype(element::operator=::n)>::type>::type>’
1515
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:6:16: note: candidates are: ‘void element::operator=(const element&)’
16-
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:16: note: ‘template<class auto:93> element& element::operator=(auto:93&&)’
16+
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:16: note: ‘template<class auto:94> element& element::operator=(auto:94&&)’
1717
pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here

regression-tests/test-results/gcc-10-c++20/pure2-default-arguments.cpp.output

+29-29
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
11
In file included from pure2-default-arguments.cpp:7:
22
../../../include/cpp2util.h:2086:28: error: local variable ‘obj’ may not appear in this context
3-
2086 |
3+
2086 | // Value case
44
| ^
55
../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’
6-
2047 | if constexpr (std::is_same_v< CPP2_TYPEOF(operator_as< 8>(x)), T >) { if (x.index() == 8) return operator_as<8>(x); }
7-
| ^~~~~~~~~~~
6+
2047 | {
7+
| ^
88
../../../include/cpp2util.h:2086:15: note: in expansion of macro ‘CPP2_FORWARD’
9-
2086 |
10-
| ^
9+
2086 | // Value case
10+
| ^~~~
1111
../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’
12-
2107 | if constexpr (std::is_same_v< CPP2_TYPEOF(operator_as<18>(x)), T >) { if (x.index() == 18) return operator_as<18>(x); }
13-
| ^~~~~~~~~~~~~~~~~~~~~~~~
12+
2107 |
13+
| ^
1414
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’
1515
2137 | }
1616
| ^
1717
pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’
1818
../../../include/cpp2util.h:2086:92: error: local variable ‘params’ may not appear in this context
19-
2086 |
19+
2086 | // Value case
2020
| ^
2121
../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’
22-
2047 | if constexpr (std::is_same_v< CPP2_TYPEOF(operator_as< 8>(x)), T >) { if (x.index() == 8) return operator_as<8>(x); }
23-
| ^~~~~~~~~~~
22+
2047 | {
23+
| ^
2424
../../../include/cpp2util.h:2086:79: note: in expansion of macro ‘CPP2_FORWARD’
25-
2086 |
25+
2086 | // Value case
2626
| ^
2727
../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’
28-
2107 | if constexpr (std::is_same_v< CPP2_TYPEOF(operator_as<18>(x)), T >) { if (x.index() == 18) return operator_as<18>(x); }
29-
| ^~~~~~~~~~~~~~~~~~~~~~~~
28+
2107 |
29+
| ^
3030
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’
3131
2137 | }
3232
| ^
3333
pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’
3434
../../../include/cpp2util.h:2087:74: error: local variable ‘obj’ may not appear in this context
35-
2087 | template<typename T, typename... Ts>
36-
| ^
35+
2087 | else if constexpr (requires{ bool{ *std::any_cast<CPP2_TYPEOF(value)>(&x) == value }; }) {
36+
| ^~~
3737
../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’
38-
2047 | if constexpr (std::is_same_v< CPP2_TYPEOF(operator_as< 8>(x)), T >) { if (x.index() == 8) return operator_as<8>(x); }
39-
| ^~~~~~~~~~~
38+
2047 | {
39+
| ^
4040
../../../include/cpp2util.h:2087:61: note: in expansion of macro ‘CPP2_FORWARD’
41-
2087 | template<typename T, typename... Ts>
42-
| ^
41+
2087 | else if constexpr (requires{ bool{ *std::any_cast<CPP2_TYPEOF(value)>(&x) == value }; }) {
42+
| ^~~~~~~~~~~~
4343
../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’
44-
2107 | if constexpr (std::is_same_v< CPP2_TYPEOF(operator_as<18>(x)), T >) { if (x.index() == 18) return operator_as<18>(x); }
45-
| ^~~~~~~~~~~~~~~~~~~~~~~~
44+
2107 |
45+
| ^
4646
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’
4747
2137 | }
4848
| ^
4949
pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’
5050
../../../include/cpp2util.h:2087:93: error: local variable ‘params’ may not appear in this context
51-
2087 | template<typename T, typename... Ts>
52-
| ^
51+
2087 | else if constexpr (requires{ bool{ *std::any_cast<CPP2_TYPEOF(value)>(&x) == value }; }) {
52+
| ^~
5353
../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’
54-
2047 | if constexpr (std::is_same_v< CPP2_TYPEOF(operator_as< 8>(x)), T >) { if (x.index() == 8) return operator_as<8>(x); }
55-
| ^~~~~~~~~~~
54+
2047 | {
55+
| ^
5656
../../../include/cpp2util.h:2087:80: note: in expansion of macro ‘CPP2_FORWARD’
57-
2087 | template<typename T, typename... Ts>
58-
| ^
57+
2087 | else if constexpr (requires{ bool{ *std::any_cast<CPP2_TYPEOF(value)>(&x) == value }; }) {
58+
| ^~~~~~~~~~~~
5959
../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’
60-
2107 | if constexpr (std::is_same_v< CPP2_TYPEOF(operator_as<18>(x)), T >) { if (x.index() == 18) return operator_as<18>(x); }
61-
| ^~~~~~~~~~~~~~~~~~~~~~~~
60+
2107 |
61+
| ^
6262
../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’
6363
2137 | }
6464
| ^

regression-tests/test-results/gcc-10-c++20/pure2-print.cpp.output

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ pure2-print.cpp2:68:1: note: in expansion of macro ‘CPP2_REQUIRES_’
99
pure2-print.cpp2:97:1: note: in expansion of macro ‘CPP2_REQUIRES_’
1010
pure2-print.cpp2:9:41: error: ‘constexpr const T outer::object_alias’ is not a static data member of ‘class outer’
1111
pure2-print.cpp2:9:48: error: template definition of non-template ‘constexpr const T outer::object_alias’
12-
pure2-print.cpp2:67:14: error: no declaration matches ‘void outer::mytype::variadic(const auto:93& ...) requires (is_convertible_v<typename std::remove_cv<typename std::remove_reference<decltype(outer::mytype::variadic::x)>::type>::type, int> && ...)’
13-
pure2-print.cpp2:67:29: note: candidate is: ‘template<class ... auto:92> static void outer::mytype::variadic(const auto:92& ...)’
12+
pure2-print.cpp2:67:14: error: no declaration matches ‘void outer::mytype::variadic(const auto:94& ...) requires (is_convertible_v<typename std::remove_cv<typename std::remove_reference<decltype(outer::mytype::variadic::x)>::type>::type, int> && ...)’
13+
pure2-print.cpp2:67:29: note: candidate is: ‘template<class ... auto:93> static void outer::mytype::variadic(const auto:93& ...)’
1414
pure2-print.cpp2:10:19: note: ‘class outer::mytype’ defined here
1515
pure2-print.cpp2:96:37: error: no declaration matches ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::impl::cmp_greater_eq(sizeof ... (Args ...), 0)’
1616
pure2-print.cpp2:96:37: note: no functions named ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::impl::cmp_greater_eq(sizeof ... (Args ...), 0)’
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
mixed-bounds-safety-with-assert.cpp2(11) void print_subrange(const auto:96&, cpp2::impl::in<int>, cpp2::impl::in<int>) [with auto:96 = std::vector<int>; cpp2::impl::in<int> = const int]: Bounds safety violation
1+
mixed-bounds-safety-with-assert.cpp2(11) void print_subrange(const auto:112&, cpp2::impl::in<int>, cpp2::impl::in<int>) [with auto:112 = std::vector<int>; cpp2::impl::in<int> = const int]: Bounds safety violation

0 commit comments

Comments
 (0)