From 1e56dca9986921a465b26789b3e76430ebf3950e Mon Sep 17 00:00:00 2001 From: Neil Henderson Date: Tue, 3 Sep 2024 14:13:59 +1000 Subject: [PATCH 1/3] Add a `cpp2::range` ctor which takes 2 different types Use a CTAD deduction guide to deduce the `std::common_type` for both types (if a common one exists). This allows code like the following to compile without integer precision conversion warnings: ``` for 0 ..< vector.size() do (e) { ... } ``` since the integer literal 0 and the size expression evaluate as different signed/unsigned types. --- include/cpp2util.h | 28 +++++++ regression-tests/pure2-range-operators.cpp2 | 5 ++ .../pure2-last-use.cpp.output | 74 +++++++++++++++++++ .../pure2-range-operators.cpp.execution | 10 +++ .../mixed-bounds-check.cpp.execution | 2 +- ...ed-bounds-safety-with-assert.cpp.execution | 2 +- ...-safety-3-contract-violation.cpp.execution | 2 +- ...me-safety-and-null-contracts.cpp.execution | 2 +- ...re2-assert-expected-not-null.cpp.execution | 2 +- ...re2-assert-optional-not-null.cpp.execution | 2 +- ...2-assert-shared-ptr-not-null.cpp.execution | 2 +- ...2-assert-unique-ptr-not-null.cpp.execution | 2 +- .../pure2-last-use.cpp.output | 74 +++++++++++++++++++ .../pure2-range-operators.cpp.execution | 10 +++ .../pure2-range-operators.cpp.execution | 10 +++ .../pure2-last-use.cpp.output | 74 +++++++++++++++++++ .../pure2-range-operators.cpp.output | 2 +- .../mixed-bounds-check.cpp.execution | 2 +- ...ed-bounds-safety-with-assert.cpp.execution | 2 +- ...-safety-3-contract-violation.cpp.execution | 2 +- ...me-safety-and-null-contracts.cpp.execution | 2 +- ...re2-assert-optional-not-null.cpp.execution | 2 +- ...2-assert-shared-ptr-not-null.cpp.execution | 2 +- ...2-assert-unique-ptr-not-null.cpp.execution | 2 +- .../clang-15-c++20/pure2-last-use.cpp.output | 74 +++++++++++++++++++ .../pure2-range-operators.cpp.execution | 10 +++ .../clang-18-c++20/pure2-last-use.cpp.output | 74 +++++++++++++++++++ .../pure2-range-operators.cpp.execution | 10 +++ .../pure2-last-use.cpp.output | 74 +++++++++++++++++++ .../pure2-range-operators.cpp.execution | 10 +++ .../pure2-default-arguments.cpp.output | 68 ++++++++--------- .../pure2-range-operators.cpp.execution | 10 +++ ...mixed-bugfix-for-ufcs-non-local.cpp.output | 20 ++--- .../pure2-range-operators.cpp.execution | 10 +++ ...mixed-bugfix-for-ufcs-non-local.cpp.output | 20 ++--- .../pure2-default-arguments.cpp.execution | 2 +- .../pure2-range-operators.cpp.execution | 13 +++- .../pure2-assert-expected-not-null.cpp.output | 6 +- .../msvc-2022-c++20/pure2-last-use.cpp.output | 12 +++ .../pure2-range-operators.cpp.execution | 10 +++ .../pure2-range-operators.cpp.execution | 10 +++ .../test-results/pure2-range-operators.cpp | 5 ++ 42 files changed, 678 insertions(+), 77 deletions(-) create mode 100644 regression-tests/test-results/apple-clang-14-c++2b/pure2-last-use.cpp.output create mode 100644 regression-tests/test-results/apple-clang-15-c++2b/pure2-last-use.cpp.output create mode 100644 regression-tests/test-results/clang-15-c++20-libcpp/pure2-last-use.cpp.output create mode 100644 regression-tests/test-results/clang-15-c++20/pure2-last-use.cpp.output create mode 100644 regression-tests/test-results/clang-18-c++20/pure2-last-use.cpp.output create mode 100644 regression-tests/test-results/clang-18-c++23-libcpp/pure2-last-use.cpp.output diff --git a/include/cpp2util.h b/include/cpp2util.h index 1ee0a06f7..fab48648a 100644 --- a/include/cpp2util.h +++ b/include/cpp2util.h @@ -746,6 +746,11 @@ concept valid_custom_is_operator = predicate_member_fun || brace_initializable_to> ); +template +concept has_common_type = requires (T t, U u) { + typename std::common_type_t; +}; + //----------------------------------------------------------------------- // // General helpers @@ -2429,6 +2434,19 @@ class range } } + // When the first & last types are different, use a CTAD deduction guide + // to find the `std::common_type` for them, if one exists. See below + // after the class definition for the deduction guide. + template + requires has_common_type + range( + T const& f, + U const& l, + bool include_last = false + ) + : range(f, l, include_last) + {} + class iterator { TT first = T{}; @@ -2564,6 +2582,16 @@ class range } }; +// CTAD deduction guide for the `range` constructor that takes two different types. +// Deduces the `std::common_type` for them, if one exists. +template + requires has_common_type +range( + T const& f, + U const& l, + bool include_last = false +) -> range>; + template auto contains(range const& r, T const& t) -> bool diff --git a/regression-tests/pure2-range-operators.cpp2 b/regression-tests/pure2-range-operators.cpp2 index b447075c0..9bd4cae89 100644 --- a/regression-tests/pure2-range-operators.cpp2 +++ b/regression-tests/pure2-range-operators.cpp2 @@ -13,6 +13,11 @@ main: () = { std::cout << " (e)$ (v[e])$\n"; } + std::cout << "\nAnd test the range when mixing signed & unsigned types:\n"; + for 0 ..< v.size() do (e) { + std::cout << " (e)$ (v[e])$\n"; + } + all_about: std::list = ( "Hokey", "Pokey" ); diff --git a/regression-tests/test-results/apple-clang-14-c++2b/pure2-last-use.cpp.output b/regression-tests/test-results/apple-clang-14-c++2b/pure2-last-use.cpp.output new file mode 100644 index 000000000..6b03c3909 --- /dev/null +++ b/regression-tests/test-results/apple-clang-14-c++2b/pure2-last-use.cpp.output @@ -0,0 +1,74 @@ +pure2-last-use.cpp2:273:36: error: expected variable name or 'this' in lambda capture list + public: std::add_pointer_t unnamed_param_1)> g; + ^ +pure2-last-use.cpp2:329:2: error: expected '>' +}; + ^ +pure2-last-use.cpp2:273:30: note: to match this '<' + public: std::add_pointer_t unnamed_param_1)> g; + ^ +pure2-last-use.cpp2:344:16: error: no template named 'move_only_function' in namespace 'std' + public: std::move_only_function b; + ~~~~~^ +pure2-last-use.cpp2:348:161: error: no member named 'move_only_function' in namespace 'std' +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ~~~~~^ +../../../include/cpp2util.h:10008:43: note: expanded from macro 'CPP2_REQUIRES_' + #define CPP2_REQUIRES_(...) requires (__VA_ARGS__) + ^~~~~~~~~~~ +pure2-last-use.cpp2:348:188: error: expected expression +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ^ +pure2-last-use.cpp2:348:193: error: use of address-of-label extension outside of a function body +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ^ +pure2-last-use.cpp2:773:69: error: no template named 'move_only_function' in namespace 'std' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ~~~~~^ +pure2-last-use.cpp2:773:93: error: expected variable name or 'this' in lambda capture list +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:156: error: expected unqualified-id +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:160: error: expected '>' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:87: note: to match this '<' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:160: error: expected ')' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:17: note: to match this '(' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:271:7: error: missing '}' at end of definition of 'issue_857_4' +class issue_857_4 { + ^ +pure2-last-use.cpp2:905:1: note: still within definition of 'issue_857_4' here +namespace captures { +^ +pure2-last-use.cpp2:279:272: error: no member named 'move_only_function' in namespace 'std' +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ~~~~~^ +pure2-last-use.cpp2:279:299: error: expected expression +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ^ +pure2-last-use.cpp2:279:304: error: use of address-of-label extension outside of a function body +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ^ +pure2-last-use.cpp2:278:14: error: out-of-line definition of 'issue_857_4' does not match any declaration in 'issue_857_4' +issue_857_4::issue_857_4(auto&& f_, auto&& g_, auto&& mf_, auto&& mg_) + ^~~~~~~~~~~ +pure2-last-use.cpp2:281:272: error: member initializer 'g' does not name a non-static data member or base class + , g{ CPP2_FORWARD(g_) } + ^~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:282:272: error: member initializer 'mf' does not name a non-static data member or base class + , mf{ CPP2_FORWARD(mf_) } + ^~~~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:283:272: error: member initializer 'mg' does not name a non-static data member or base class + , mg{ CPP2_FORWARD(mg_) }{} + ^~~~~~~~~~~~~~~~~~~~~~~ +fatal error: too many errors emitted, stopping now [-ferror-limit=] +20 errors generated. diff --git a/regression-tests/test-results/apple-clang-14-c++2b/pure2-range-operators.cpp.execution b/regression-tests/test-results/apple-clang-14-c++2b/pure2-range-operators.cpp.execution index 9168b08ea..100e0a464 100644 --- a/regression-tests/test-results/apple-clang-14-c++2b/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/apple-clang-14-c++2b/pure2-range-operators.cpp.execution @@ -15,6 +15,16 @@ And from indexes 1..=5 they are: 4 Elephant 5 Flicker +And test the range when mixing signed & unsigned types: + 0 Aardvark + 1 Baboon + 2 Cat + 3 Dolphin + 4 Elephant + 5 Flicker + 6 Grue + 7 Wumpus + Make sure non-random-access iterators work: Hokey Pokey diff --git a/regression-tests/test-results/apple-clang-15-c++2b/mixed-bounds-check.cpp.execution b/regression-tests/test-results/apple-clang-15-c++2b/mixed-bounds-check.cpp.execution index 8c939be08..91a25ada8 100644 --- a/regression-tests/test-results/apple-clang-15-c++2b/mixed-bounds-check.cpp.execution +++ b/regression-tests/test-results/apple-clang-15-c++2b/mixed-bounds-check.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(1103) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] +../../../include/cpp2util.h(1108) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] diff --git a/regression-tests/test-results/apple-clang-15-c++2b/mixed-bounds-safety-with-assert.cpp.execution b/regression-tests/test-results/apple-clang-15-c++2b/mixed-bounds-safety-with-assert.cpp.execution index 148e3b7d8..638ccfecc 100644 --- a/regression-tests/test-results/apple-clang-15-c++2b/mixed-bounds-safety-with-assert.cpp.execution +++ b/regression-tests/test-results/apple-clang-15-c++2b/mixed-bounds-safety-with-assert.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(915) : Bounds safety violation +../../../include/cpp2util.h(920) : Bounds safety violation diff --git a/regression-tests/test-results/apple-clang-15-c++2b/mixed-initialization-safety-3-contract-violation.cpp.execution b/regression-tests/test-results/apple-clang-15-c++2b/mixed-initialization-safety-3-contract-violation.cpp.execution index d1b29d5d4..2e659ac3e 100644 --- a/regression-tests/test-results/apple-clang-15-c++2b/mixed-initialization-safety-3-contract-violation.cpp.execution +++ b/regression-tests/test-results/apple-clang-15-c++2b/mixed-initialization-safety-3-contract-violation.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(915) : Contract violation: fill: value must contain at least count elements +../../../include/cpp2util.h(920) : Contract violation: fill: value must contain at least count elements diff --git a/regression-tests/test-results/apple-clang-15-c++2b/mixed-lifetime-safety-and-null-contracts.cpp.execution b/regression-tests/test-results/apple-clang-15-c++2b/mixed-lifetime-safety-and-null-contracts.cpp.execution index 7fd8ae38b..c848bf98a 100644 --- a/regression-tests/test-results/apple-clang-15-c++2b/mixed-lifetime-safety-and-null-contracts.cpp.execution +++ b/regression-tests/test-results/apple-clang-15-c++2b/mixed-lifetime-safety-and-null-contracts.cpp.execution @@ -1,2 +1,2 @@ sending error to my framework... [dynamic null dereference attempt detected] -from source location: ../../../include/cpp2util.h(994) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&] +from source location: ../../../include/cpp2util.h(999) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&] diff --git a/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-expected-not-null.cpp.execution b/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-expected-not-null.cpp.execution index d944874ab..58bf51d65 100644 --- a/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-expected-not-null.cpp.execution +++ b/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-expected-not-null.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(994) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::expected]: Null safety violation: std::expected has an unexpected value +../../../include/cpp2util.h(999) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::expected]: Null safety violation: std::expected has an unexpected value diff --git a/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-optional-not-null.cpp.execution b/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-optional-not-null.cpp.execution index 19ed72ceb..8ed66e3a3 100644 --- a/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-optional-not-null.cpp.execution +++ b/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-optional-not-null.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(994) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional]: Null safety violation: std::optional does not contain a value +../../../include/cpp2util.h(999) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional]: Null safety violation: std::optional does not contain a value diff --git a/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-shared-ptr-not-null.cpp.execution b/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-shared-ptr-not-null.cpp.execution index bae46a958..092ef8093 100644 --- a/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-shared-ptr-not-null.cpp.execution +++ b/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-shared-ptr-not-null.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(994) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr]: Null safety violation: std::shared_ptr is empty +../../../include/cpp2util.h(999) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr]: Null safety violation: std::shared_ptr is empty diff --git a/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-unique-ptr-not-null.cpp.execution b/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-unique-ptr-not-null.cpp.execution index 8e194df28..acc10a1c1 100644 --- a/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-unique-ptr-not-null.cpp.execution +++ b/regression-tests/test-results/apple-clang-15-c++2b/pure2-assert-unique-ptr-not-null.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(994) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr]: Null safety violation: std::unique_ptr is empty +../../../include/cpp2util.h(999) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr]: Null safety violation: std::unique_ptr is empty diff --git a/regression-tests/test-results/apple-clang-15-c++2b/pure2-last-use.cpp.output b/regression-tests/test-results/apple-clang-15-c++2b/pure2-last-use.cpp.output new file mode 100644 index 000000000..6b03c3909 --- /dev/null +++ b/regression-tests/test-results/apple-clang-15-c++2b/pure2-last-use.cpp.output @@ -0,0 +1,74 @@ +pure2-last-use.cpp2:273:36: error: expected variable name or 'this' in lambda capture list + public: std::add_pointer_t unnamed_param_1)> g; + ^ +pure2-last-use.cpp2:329:2: error: expected '>' +}; + ^ +pure2-last-use.cpp2:273:30: note: to match this '<' + public: std::add_pointer_t unnamed_param_1)> g; + ^ +pure2-last-use.cpp2:344:16: error: no template named 'move_only_function' in namespace 'std' + public: std::move_only_function b; + ~~~~~^ +pure2-last-use.cpp2:348:161: error: no member named 'move_only_function' in namespace 'std' +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ~~~~~^ +../../../include/cpp2util.h:10008:43: note: expanded from macro 'CPP2_REQUIRES_' + #define CPP2_REQUIRES_(...) requires (__VA_ARGS__) + ^~~~~~~~~~~ +pure2-last-use.cpp2:348:188: error: expected expression +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ^ +pure2-last-use.cpp2:348:193: error: use of address-of-label extension outside of a function body +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ^ +pure2-last-use.cpp2:773:69: error: no template named 'move_only_function' in namespace 'std' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ~~~~~^ +pure2-last-use.cpp2:773:93: error: expected variable name or 'this' in lambda capture list +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:156: error: expected unqualified-id +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:160: error: expected '>' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:87: note: to match this '<' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:160: error: expected ')' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:17: note: to match this '(' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:271:7: error: missing '}' at end of definition of 'issue_857_4' +class issue_857_4 { + ^ +pure2-last-use.cpp2:905:1: note: still within definition of 'issue_857_4' here +namespace captures { +^ +pure2-last-use.cpp2:279:272: error: no member named 'move_only_function' in namespace 'std' +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ~~~~~^ +pure2-last-use.cpp2:279:299: error: expected expression +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ^ +pure2-last-use.cpp2:279:304: error: use of address-of-label extension outside of a function body +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ^ +pure2-last-use.cpp2:278:14: error: out-of-line definition of 'issue_857_4' does not match any declaration in 'issue_857_4' +issue_857_4::issue_857_4(auto&& f_, auto&& g_, auto&& mf_, auto&& mg_) + ^~~~~~~~~~~ +pure2-last-use.cpp2:281:272: error: member initializer 'g' does not name a non-static data member or base class + , g{ CPP2_FORWARD(g_) } + ^~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:282:272: error: member initializer 'mf' does not name a non-static data member or base class + , mf{ CPP2_FORWARD(mf_) } + ^~~~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:283:272: error: member initializer 'mg' does not name a non-static data member or base class + , mg{ CPP2_FORWARD(mg_) }{} + ^~~~~~~~~~~~~~~~~~~~~~~ +fatal error: too many errors emitted, stopping now [-ferror-limit=] +20 errors generated. diff --git a/regression-tests/test-results/apple-clang-15-c++2b/pure2-range-operators.cpp.execution b/regression-tests/test-results/apple-clang-15-c++2b/pure2-range-operators.cpp.execution index 9168b08ea..100e0a464 100644 --- a/regression-tests/test-results/apple-clang-15-c++2b/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/apple-clang-15-c++2b/pure2-range-operators.cpp.execution @@ -15,6 +15,16 @@ And from indexes 1..=5 they are: 4 Elephant 5 Flicker +And test the range when mixing signed & unsigned types: + 0 Aardvark + 1 Baboon + 2 Cat + 3 Dolphin + 4 Elephant + 5 Flicker + 6 Grue + 7 Wumpus + Make sure non-random-access iterators work: Hokey Pokey diff --git a/regression-tests/test-results/clang-12-c++20/pure2-range-operators.cpp.execution b/regression-tests/test-results/clang-12-c++20/pure2-range-operators.cpp.execution index 9168b08ea..100e0a464 100644 --- a/regression-tests/test-results/clang-12-c++20/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/clang-12-c++20/pure2-range-operators.cpp.execution @@ -15,6 +15,16 @@ And from indexes 1..=5 they are: 4 Elephant 5 Flicker +And test the range when mixing signed & unsigned types: + 0 Aardvark + 1 Baboon + 2 Cat + 3 Dolphin + 4 Elephant + 5 Flicker + 6 Grue + 7 Wumpus + Make sure non-random-access iterators work: Hokey Pokey diff --git a/regression-tests/test-results/clang-15-c++20-libcpp/pure2-last-use.cpp.output b/regression-tests/test-results/clang-15-c++20-libcpp/pure2-last-use.cpp.output new file mode 100644 index 000000000..6b03c3909 --- /dev/null +++ b/regression-tests/test-results/clang-15-c++20-libcpp/pure2-last-use.cpp.output @@ -0,0 +1,74 @@ +pure2-last-use.cpp2:273:36: error: expected variable name or 'this' in lambda capture list + public: std::add_pointer_t unnamed_param_1)> g; + ^ +pure2-last-use.cpp2:329:2: error: expected '>' +}; + ^ +pure2-last-use.cpp2:273:30: note: to match this '<' + public: std::add_pointer_t unnamed_param_1)> g; + ^ +pure2-last-use.cpp2:344:16: error: no template named 'move_only_function' in namespace 'std' + public: std::move_only_function b; + ~~~~~^ +pure2-last-use.cpp2:348:161: error: no member named 'move_only_function' in namespace 'std' +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ~~~~~^ +../../../include/cpp2util.h:10008:43: note: expanded from macro 'CPP2_REQUIRES_' + #define CPP2_REQUIRES_(...) requires (__VA_ARGS__) + ^~~~~~~~~~~ +pure2-last-use.cpp2:348:188: error: expected expression +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ^ +pure2-last-use.cpp2:348:193: error: use of address-of-label extension outside of a function body +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ^ +pure2-last-use.cpp2:773:69: error: no template named 'move_only_function' in namespace 'std' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ~~~~~^ +pure2-last-use.cpp2:773:93: error: expected variable name or 'this' in lambda capture list +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:156: error: expected unqualified-id +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:160: error: expected '>' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:87: note: to match this '<' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:160: error: expected ')' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:17: note: to match this '(' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:271:7: error: missing '}' at end of definition of 'issue_857_4' +class issue_857_4 { + ^ +pure2-last-use.cpp2:905:1: note: still within definition of 'issue_857_4' here +namespace captures { +^ +pure2-last-use.cpp2:279:272: error: no member named 'move_only_function' in namespace 'std' +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ~~~~~^ +pure2-last-use.cpp2:279:299: error: expected expression +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ^ +pure2-last-use.cpp2:279:304: error: use of address-of-label extension outside of a function body +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ^ +pure2-last-use.cpp2:278:14: error: out-of-line definition of 'issue_857_4' does not match any declaration in 'issue_857_4' +issue_857_4::issue_857_4(auto&& f_, auto&& g_, auto&& mf_, auto&& mg_) + ^~~~~~~~~~~ +pure2-last-use.cpp2:281:272: error: member initializer 'g' does not name a non-static data member or base class + , g{ CPP2_FORWARD(g_) } + ^~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:282:272: error: member initializer 'mf' does not name a non-static data member or base class + , mf{ CPP2_FORWARD(mf_) } + ^~~~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:283:272: error: member initializer 'mg' does not name a non-static data member or base class + , mg{ CPP2_FORWARD(mg_) }{} + ^~~~~~~~~~~~~~~~~~~~~~~ +fatal error: too many errors emitted, stopping now [-ferror-limit=] +20 errors generated. diff --git a/regression-tests/test-results/clang-15-c++20-libcpp/pure2-range-operators.cpp.output b/regression-tests/test-results/clang-15-c++20-libcpp/pure2-range-operators.cpp.output index 8a8cf2904..840077657 100644 --- a/regression-tests/test-results/clang-15-c++20-libcpp/pure2-range-operators.cpp.output +++ b/regression-tests/test-results/clang-15-c++20-libcpp/pure2-range-operators.cpp.output @@ -1,4 +1,4 @@ -pure2-range-operators.cpp2:44:34: error: expected namespace name +pure2-range-operators.cpp2:49:34: error: expected namespace name using namespace std::views; ~~~~~^ 1 error generated. diff --git a/regression-tests/test-results/clang-15-c++20/mixed-bounds-check.cpp.execution b/regression-tests/test-results/clang-15-c++20/mixed-bounds-check.cpp.execution index 8c939be08..91a25ada8 100644 --- a/regression-tests/test-results/clang-15-c++20/mixed-bounds-check.cpp.execution +++ b/regression-tests/test-results/clang-15-c++20/mixed-bounds-check.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(1103) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] +../../../include/cpp2util.h(1108) decltype(auto) cpp2::impl::assert_in_bounds(auto &&, std::source_location) [arg = 5, x:auto = std::vector]: Bounds safety violation: out of bounds access attempt detected - attempted access at index 5, [min,max] range is [0,4] diff --git a/regression-tests/test-results/clang-15-c++20/mixed-bounds-safety-with-assert.cpp.execution b/regression-tests/test-results/clang-15-c++20/mixed-bounds-safety-with-assert.cpp.execution index 148e3b7d8..638ccfecc 100644 --- a/regression-tests/test-results/clang-15-c++20/mixed-bounds-safety-with-assert.cpp.execution +++ b/regression-tests/test-results/clang-15-c++20/mixed-bounds-safety-with-assert.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(915) : Bounds safety violation +../../../include/cpp2util.h(920) : Bounds safety violation diff --git a/regression-tests/test-results/clang-15-c++20/mixed-initialization-safety-3-contract-violation.cpp.execution b/regression-tests/test-results/clang-15-c++20/mixed-initialization-safety-3-contract-violation.cpp.execution index d1b29d5d4..2e659ac3e 100644 --- a/regression-tests/test-results/clang-15-c++20/mixed-initialization-safety-3-contract-violation.cpp.execution +++ b/regression-tests/test-results/clang-15-c++20/mixed-initialization-safety-3-contract-violation.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(915) : Contract violation: fill: value must contain at least count elements +../../../include/cpp2util.h(920) : Contract violation: fill: value must contain at least count elements diff --git a/regression-tests/test-results/clang-15-c++20/mixed-lifetime-safety-and-null-contracts.cpp.execution b/regression-tests/test-results/clang-15-c++20/mixed-lifetime-safety-and-null-contracts.cpp.execution index 7fd8ae38b..c848bf98a 100644 --- a/regression-tests/test-results/clang-15-c++20/mixed-lifetime-safety-and-null-contracts.cpp.execution +++ b/regression-tests/test-results/clang-15-c++20/mixed-lifetime-safety-and-null-contracts.cpp.execution @@ -1,2 +1,2 @@ sending error to my framework... [dynamic null dereference attempt detected] -from source location: ../../../include/cpp2util.h(994) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&] +from source location: ../../../include/cpp2util.h(999) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = int *&] diff --git a/regression-tests/test-results/clang-15-c++20/pure2-assert-optional-not-null.cpp.execution b/regression-tests/test-results/clang-15-c++20/pure2-assert-optional-not-null.cpp.execution index 19ed72ceb..8ed66e3a3 100644 --- a/regression-tests/test-results/clang-15-c++20/pure2-assert-optional-not-null.cpp.execution +++ b/regression-tests/test-results/clang-15-c++20/pure2-assert-optional-not-null.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(994) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional]: Null safety violation: std::optional does not contain a value +../../../include/cpp2util.h(999) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::optional]: Null safety violation: std::optional does not contain a value diff --git a/regression-tests/test-results/clang-15-c++20/pure2-assert-shared-ptr-not-null.cpp.execution b/regression-tests/test-results/clang-15-c++20/pure2-assert-shared-ptr-not-null.cpp.execution index bae46a958..092ef8093 100644 --- a/regression-tests/test-results/clang-15-c++20/pure2-assert-shared-ptr-not-null.cpp.execution +++ b/regression-tests/test-results/clang-15-c++20/pure2-assert-shared-ptr-not-null.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(994) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr]: Null safety violation: std::shared_ptr is empty +../../../include/cpp2util.h(999) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::shared_ptr]: Null safety violation: std::shared_ptr is empty diff --git a/regression-tests/test-results/clang-15-c++20/pure2-assert-unique-ptr-not-null.cpp.execution b/regression-tests/test-results/clang-15-c++20/pure2-assert-unique-ptr-not-null.cpp.execution index 8e194df28..acc10a1c1 100644 --- a/regression-tests/test-results/clang-15-c++20/pure2-assert-unique-ptr-not-null.cpp.execution +++ b/regression-tests/test-results/clang-15-c++20/pure2-assert-unique-ptr-not-null.cpp.execution @@ -1 +1 @@ -../../../include/cpp2util.h(994) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr]: Null safety violation: std::unique_ptr is empty +../../../include/cpp2util.h(999) decltype(auto) cpp2::impl::assert_not_null(auto &&, std::source_location) [arg:auto = std::unique_ptr]: Null safety violation: std::unique_ptr is empty diff --git a/regression-tests/test-results/clang-15-c++20/pure2-last-use.cpp.output b/regression-tests/test-results/clang-15-c++20/pure2-last-use.cpp.output new file mode 100644 index 000000000..6b03c3909 --- /dev/null +++ b/regression-tests/test-results/clang-15-c++20/pure2-last-use.cpp.output @@ -0,0 +1,74 @@ +pure2-last-use.cpp2:273:36: error: expected variable name or 'this' in lambda capture list + public: std::add_pointer_t unnamed_param_1)> g; + ^ +pure2-last-use.cpp2:329:2: error: expected '>' +}; + ^ +pure2-last-use.cpp2:273:30: note: to match this '<' + public: std::add_pointer_t unnamed_param_1)> g; + ^ +pure2-last-use.cpp2:344:16: error: no template named 'move_only_function' in namespace 'std' + public: std::move_only_function b; + ~~~~~^ +pure2-last-use.cpp2:348:161: error: no member named 'move_only_function' in namespace 'std' +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ~~~~~^ +../../../include/cpp2util.h:10008:43: note: expanded from macro 'CPP2_REQUIRES_' + #define CPP2_REQUIRES_(...) requires (__VA_ARGS__) + ^~~~~~~~~~~ +pure2-last-use.cpp2:348:188: error: expected expression +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ^ +pure2-last-use.cpp2:348:193: error: use of address-of-label extension outside of a function body +CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + ^ +pure2-last-use.cpp2:773:69: error: no template named 'move_only_function' in namespace 'std' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ~~~~~^ +pure2-last-use.cpp2:773:93: error: expected variable name or 'this' in lambda capture list +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:156: error: expected unqualified-id +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:160: error: expected '>' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:87: note: to match this '<' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:160: error: expected ')' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:773:17: note: to match this '(' +auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + ^ +pure2-last-use.cpp2:271:7: error: missing '}' at end of definition of 'issue_857_4' +class issue_857_4 { + ^ +pure2-last-use.cpp2:905:1: note: still within definition of 'issue_857_4' here +namespace captures { +^ +pure2-last-use.cpp2:279:272: error: no member named 'move_only_function' in namespace 'std' +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ~~~~~^ +pure2-last-use.cpp2:279:299: error: expected expression +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ^ +pure2-last-use.cpp2:279:304: error: use of address-of-label extension outside of a function body +requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + ^ +pure2-last-use.cpp2:278:14: error: out-of-line definition of 'issue_857_4' does not match any declaration in 'issue_857_4' +issue_857_4::issue_857_4(auto&& f_, auto&& g_, auto&& mf_, auto&& mg_) + ^~~~~~~~~~~ +pure2-last-use.cpp2:281:272: error: member initializer 'g' does not name a non-static data member or base class + , g{ CPP2_FORWARD(g_) } + ^~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:282:272: error: member initializer 'mf' does not name a non-static data member or base class + , mf{ CPP2_FORWARD(mf_) } + ^~~~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:283:272: error: member initializer 'mg' does not name a non-static data member or base class + , mg{ CPP2_FORWARD(mg_) }{} + ^~~~~~~~~~~~~~~~~~~~~~~ +fatal error: too many errors emitted, stopping now [-ferror-limit=] +20 errors generated. diff --git a/regression-tests/test-results/clang-15-c++20/pure2-range-operators.cpp.execution b/regression-tests/test-results/clang-15-c++20/pure2-range-operators.cpp.execution index 9168b08ea..100e0a464 100644 --- a/regression-tests/test-results/clang-15-c++20/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/clang-15-c++20/pure2-range-operators.cpp.execution @@ -15,6 +15,16 @@ And from indexes 1..=5 they are: 4 Elephant 5 Flicker +And test the range when mixing signed & unsigned types: + 0 Aardvark + 1 Baboon + 2 Cat + 3 Dolphin + 4 Elephant + 5 Flicker + 6 Grue + 7 Wumpus + Make sure non-random-access iterators work: Hokey Pokey diff --git a/regression-tests/test-results/clang-18-c++20/pure2-last-use.cpp.output b/regression-tests/test-results/clang-18-c++20/pure2-last-use.cpp.output new file mode 100644 index 000000000..4162dcfa1 --- /dev/null +++ b/regression-tests/test-results/clang-18-c++20/pure2-last-use.cpp.output @@ -0,0 +1,74 @@ +pure2-last-use.cpp2:273:36: error: expected variable name or 'this' in lambda capture list + 273 | public: std::add_pointer_t unnamed_param_1)> g; + | ^ +pure2-last-use.cpp2:329:2: error: expected '>' + 329 | }; + | ^ +pure2-last-use.cpp2:273:30: note: to match this '<' + 273 | public: std::add_pointer_t unnamed_param_1)> g; + | ^ +pure2-last-use.cpp2:344:16: error: no template named 'move_only_function' in namespace 'std' + 344 | public: std::move_only_function b; + | ~~~~~^ +pure2-last-use.cpp2:348:161: error: no member named 'move_only_function' in namespace 'std' + 348 | CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + | ~~~~~^ +../../../include/cpp2util.h:10008:43: note: expanded from macro 'CPP2_REQUIRES_' + 10008 | #define CPP2_REQUIRES_(...) requires (__VA_ARGS__) + | ^~~~~~~~~~~ +pure2-last-use.cpp2:348:188: error: expected expression + 348 | CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + | ^ +pure2-last-use.cpp2:348:193: error: use of address-of-label extension outside of a function body + 348 | CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + | ^ +pure2-last-use.cpp2:773:69: error: no template named 'move_only_function' in namespace 'std' + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ~~~~~^ +pure2-last-use.cpp2:773:93: error: expected variable name or 'this' in lambda capture list + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:773:156: error: expected unqualified-id + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:773:160: error: expected '>' + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:773:87: note: to match this '<' + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:773:160: error: expected ')' + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:773:17: note: to match this '(' + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:271:7: error: missing '}' at end of definition of 'issue_857_4' + 271 | class issue_857_4 { + | ^ +pure2-last-use.cpp2:905:1: note: still within definition of 'issue_857_4' here + 905 | namespace captures { + | ^ +pure2-last-use.cpp2:279:272: error: no member named 'move_only_function' in namespace 'std' + 279 | requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + | ~~~~~^ +pure2-last-use.cpp2:279:299: error: expected expression + 279 | requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + | ^ +pure2-last-use.cpp2:279:304: error: use of address-of-label extension outside of a function body + 279 | requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + | ^ +pure2-last-use.cpp2:278:14: error: out-of-line definition of 'issue_857_4' does not match any declaration in 'issue_857_4' + 278 | issue_857_4::issue_857_4(auto&& f_, auto&& g_, auto&& mf_, auto&& mg_) + | ^~~~~~~~~~~ +pure2-last-use.cpp2:281:272: error: member initializer 'g' does not name a non-static data member or base class + 281 | , g{ CPP2_FORWARD(g_) } + | ^~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:282:272: error: member initializer 'mf' does not name a non-static data member or base class + 282 | , mf{ CPP2_FORWARD(mf_) } + | ^~~~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:283:272: error: member initializer 'mg' does not name a non-static data member or base class + 283 | , mg{ CPP2_FORWARD(mg_) }{} + | ^~~~~~~~~~~~~~~~~~~~~~~ +fatal error: too many errors emitted, stopping now [-ferror-limit=] +20 errors generated. diff --git a/regression-tests/test-results/clang-18-c++20/pure2-range-operators.cpp.execution b/regression-tests/test-results/clang-18-c++20/pure2-range-operators.cpp.execution index df04174c1..9937f85c3 100644 --- a/regression-tests/test-results/clang-18-c++20/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/clang-18-c++20/pure2-range-operators.cpp.execution @@ -15,6 +15,16 @@ And from indexes 1..=5 they are: 4 Elephant 5 Flicker +And test the range when mixing signed & unsigned types: + 0 Aardvark + 1 Baboon + 2 Cat + 3 Dolphin + 4 Elephant + 5 Flicker + 6 Grue + 7 Wumpus + Make sure non-random-access iterators work: Hokey Pokey diff --git a/regression-tests/test-results/clang-18-c++23-libcpp/pure2-last-use.cpp.output b/regression-tests/test-results/clang-18-c++23-libcpp/pure2-last-use.cpp.output new file mode 100644 index 000000000..4162dcfa1 --- /dev/null +++ b/regression-tests/test-results/clang-18-c++23-libcpp/pure2-last-use.cpp.output @@ -0,0 +1,74 @@ +pure2-last-use.cpp2:273:36: error: expected variable name or 'this' in lambda capture list + 273 | public: std::add_pointer_t unnamed_param_1)> g; + | ^ +pure2-last-use.cpp2:329:2: error: expected '>' + 329 | }; + | ^ +pure2-last-use.cpp2:273:30: note: to match this '<' + 273 | public: std::add_pointer_t unnamed_param_1)> g; + | ^ +pure2-last-use.cpp2:344:16: error: no template named 'move_only_function' in namespace 'std' + 344 | public: std::move_only_function b; + | ~~~~~^ +pure2-last-use.cpp2:348:161: error: no member named 'move_only_function' in namespace 'std' + 348 | CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + | ~~~~~^ +../../../include/cpp2util.h:10008:43: note: expanded from macro 'CPP2_REQUIRES_' + 10008 | #define CPP2_REQUIRES_(...) requires (__VA_ARGS__) + | ^~~~~~~~~~~ +pure2-last-use.cpp2:348:188: error: expected expression + 348 | CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + | ^ +pure2-last-use.cpp2:348:193: error: use of address-of-label extension outside of a function body + 348 | CPP2_REQUIRES_ (std::is_convertible_v>&> && std::is_convertible_v>&> && std::is_convertible_v>&>) ; + | ^ +pure2-last-use.cpp2:773:69: error: no template named 'move_only_function' in namespace 'std' + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ~~~~~^ +pure2-last-use.cpp2:773:93: error: expected variable name or 'this' in lambda capture list + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:773:156: error: expected unqualified-id + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:773:160: error: expected '>' + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:773:87: note: to match this '<' + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:773:160: error: expected ')' + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:773:17: note: to match this '(' + 773 | auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, std::move_only_function unnamed_param_1)> size) -> void; + | ^ +pure2-last-use.cpp2:271:7: error: missing '}' at end of definition of 'issue_857_4' + 271 | class issue_857_4 { + | ^ +pure2-last-use.cpp2:905:1: note: still within definition of 'issue_857_4' here + 905 | namespace captures { + | ^ +pure2-last-use.cpp2:279:272: error: no member named 'move_only_function' in namespace 'std' + 279 | requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + | ~~~~~^ +pure2-last-use.cpp2:279:299: error: expected expression + 279 | requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + | ^ +pure2-last-use.cpp2:279:304: error: use of address-of-label extension outside of a function body + 279 | requires (std::is_convertible_v>&> && std::is_convertible_v in_)>>&> && std::is_convertible_v>&> && std::is_convertible_v in_)>>&>) + | ^ +pure2-last-use.cpp2:278:14: error: out-of-line definition of 'issue_857_4' does not match any declaration in 'issue_857_4' + 278 | issue_857_4::issue_857_4(auto&& f_, auto&& g_, auto&& mf_, auto&& mg_) + | ^~~~~~~~~~~ +pure2-last-use.cpp2:281:272: error: member initializer 'g' does not name a non-static data member or base class + 281 | , g{ CPP2_FORWARD(g_) } + | ^~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:282:272: error: member initializer 'mf' does not name a non-static data member or base class + 282 | , mf{ CPP2_FORWARD(mf_) } + | ^~~~~~~~~~~~~~~~~~~~~~~ +pure2-last-use.cpp2:283:272: error: member initializer 'mg' does not name a non-static data member or base class + 283 | , mg{ CPP2_FORWARD(mg_) }{} + | ^~~~~~~~~~~~~~~~~~~~~~~ +fatal error: too many errors emitted, stopping now [-ferror-limit=] +20 errors generated. diff --git a/regression-tests/test-results/clang-18-c++23-libcpp/pure2-range-operators.cpp.execution b/regression-tests/test-results/clang-18-c++23-libcpp/pure2-range-operators.cpp.execution index df04174c1..9937f85c3 100644 --- a/regression-tests/test-results/clang-18-c++23-libcpp/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/clang-18-c++23-libcpp/pure2-range-operators.cpp.execution @@ -15,6 +15,16 @@ And from indexes 1..=5 they are: 4 Elephant 5 Flicker +And test the range when mixing signed & unsigned types: + 0 Aardvark + 1 Baboon + 2 Cat + 3 Dolphin + 4 Elephant + 5 Flicker + 6 Grue + 7 Wumpus + Make sure non-random-access iterators work: Hokey Pokey diff --git a/regression-tests/test-results/gcc-10-c++20/pure2-default-arguments.cpp.output b/regression-tests/test-results/gcc-10-c++20/pure2-default-arguments.cpp.output index 7ed50a83d..7300835e5 100644 --- a/regression-tests/test-results/gcc-10-c++20/pure2-default-arguments.cpp.output +++ b/regression-tests/test-results/gcc-10-c++20/pure2-default-arguments.cpp.output @@ -1,66 +1,66 @@ In file included from pure2-default-arguments.cpp:7: ../../../include/cpp2util.h:2086:28: error: local variable ‘obj’ may not appear in this context - 2086 | template - | ^~~ + 2086 | // std::any is and as + | ^ ../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’ - 2047 | return false; - | ^ + 2047 | return std::get_if(&x) != nullptr; + | ^~~~~~~~~~~ ../../../include/cpp2util.h:2086:15: note: in expansion of macro ‘CPP2_FORWARD’ - 2086 | template - | ^~~~~~~~~~~~ + 2086 | // std::any is and as + | ^~~~~~~~ ../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’ - 2107 | } - | ^ + 2107 | if constexpr (requires{ bool{ value(x) }; }) { + | ^~~~~~~~~~~~~~~~~~~~~~~~ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ ../../../include/cpp2util.h:2086:92: error: local variable ‘params’ may not appear in this context - 2086 | template + 2086 | // std::any is and as | ^ ../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’ - 2047 | return false; - | ^ + 2047 | return std::get_if(&x) != nullptr; + | ^~~~~~~~~~~ ../../../include/cpp2util.h:2086:79: note: in expansion of macro ‘CPP2_FORWARD’ - 2086 | template + 2086 | // std::any is and as | ^ ../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’ - 2107 | } - | ^ + 2107 | if constexpr (requires{ bool{ value(x) }; }) { + | ^~~~~~~~~~~~~~~~~~~~~~~~ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ ../../../include/cpp2util.h:2087:74: error: local variable ‘obj’ may not appear in this context - 2087 | requires (std::is_same_v && !std::is_same_v && !std::is_same_v) - | ^~~ + 2087 | // + | ^ ../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’ - 2047 | return false; - | ^ + 2047 | return std::get_if(&x) != nullptr; + | ^~~~~~~~~~~ ../../../include/cpp2util.h:2087:61: note: in expansion of macro ‘CPP2_FORWARD’ - 2087 | requires (std::is_same_v && !std::is_same_v && !std::is_same_v) - | ^~~~~~~~~~~~ + 2087 | // + | ^ ../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’ - 2107 | } - | ^ + 2107 | if constexpr (requires{ bool{ value(x) }; }) { + | ^~~~~~~~~~~~~~~~~~~~~~~~ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ ../../../include/cpp2util.h:2087:93: error: local variable ‘params’ may not appear in this context - 2087 | requires (std::is_same_v && !std::is_same_v && !std::is_same_v) - | ^~~~~~ + 2087 | // + | ^ ../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’ - 2047 | return false; - | ^ + 2047 | return std::get_if(&x) != nullptr; + | ^~~~~~~~~~~ ../../../include/cpp2util.h:2087:80: note: in expansion of macro ‘CPP2_FORWARD’ - 2087 | requires (std::is_same_v && !std::is_same_v && !std::is_same_v) - | ^~~~~~~~~~~~ + 2087 | // + | ^ ../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’ - 2107 | } - | ^ + 2107 | if constexpr (requires{ bool{ value(x) }; }) { + | ^~~~~~~~~~~~~~~~~~~~~~~~ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ pure2-default-arguments.cpp2:6:61: error: ‘std::source_location’ has not been declared diff --git a/regression-tests/test-results/gcc-10-c++20/pure2-range-operators.cpp.execution b/regression-tests/test-results/gcc-10-c++20/pure2-range-operators.cpp.execution index 9168b08ea..100e0a464 100644 --- a/regression-tests/test-results/gcc-10-c++20/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/gcc-10-c++20/pure2-range-operators.cpp.execution @@ -15,6 +15,16 @@ And from indexes 1..=5 they are: 4 Elephant 5 Flicker +And test the range when mixing signed & unsigned types: + 0 Aardvark + 1 Baboon + 2 Cat + 3 Dolphin + 4 Elephant + 5 Flicker + 6 Grue + 7 Wumpus + Make sure non-random-access iterators work: Hokey Pokey diff --git a/regression-tests/test-results/gcc-13-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output b/regression-tests/test-results/gcc-13-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output index b08a69eb0..f4d33aa19 100644 --- a/regression-tests/test-results/gcc-13-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output +++ b/regression-tests/test-results/gcc-13-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output @@ -1,41 +1,41 @@ In file included from mixed-bugfix-for-ufcs-non-local.cpp:6: ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | { + 2100 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ mixed-bugfix-for-ufcs-non-local.cpp2:13:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:13:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | { + 2100 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | { + 2100 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ mixed-bugfix-for-ufcs-non-local.cpp2:31:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:31:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | { + 2100 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ mixed-bugfix-for-ufcs-non-local.cpp2:33:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:33:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | { + 2100 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid diff --git a/regression-tests/test-results/gcc-13-c++2b/pure2-range-operators.cpp.execution b/regression-tests/test-results/gcc-13-c++2b/pure2-range-operators.cpp.execution index 9168b08ea..100e0a464 100644 --- a/regression-tests/test-results/gcc-13-c++2b/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/gcc-13-c++2b/pure2-range-operators.cpp.execution @@ -15,6 +15,16 @@ And from indexes 1..=5 they are: 4 Elephant 5 Flicker +And test the range when mixing signed & unsigned types: + 0 Aardvark + 1 Baboon + 2 Cat + 3 Dolphin + 4 Elephant + 5 Flicker + 6 Grue + 7 Wumpus + Make sure non-random-access iterators work: Hokey Pokey diff --git a/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output b/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output index b08a69eb0..f4d33aa19 100644 --- a/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output +++ b/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output @@ -1,41 +1,41 @@ In file included from mixed-bugfix-for-ufcs-non-local.cpp:6: ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | { + 2100 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ mixed-bugfix-for-ufcs-non-local.cpp2:13:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:13:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | { + 2100 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | { + 2100 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ mixed-bugfix-for-ufcs-non-local.cpp2:31:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:31:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | { + 2100 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ mixed-bugfix-for-ufcs-non-local.cpp2:33:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:33:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | { + 2100 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | + 2137 | // | ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid diff --git a/regression-tests/test-results/gcc-14-c++2b/pure2-default-arguments.cpp.execution b/regression-tests/test-results/gcc-14-c++2b/pure2-default-arguments.cpp.execution index 0d1459552..afb167feb 100644 --- a/regression-tests/test-results/gcc-14-c++2b/pure2-default-arguments.cpp.execution +++ b/regression-tests/test-results/gcc-14-c++2b/pure2-default-arguments.cpp.execution @@ -1,4 +1,4 @@ calling: int main(int, char**) 012 -a newer compiler +an older compiler 1, 1, 66 diff --git a/regression-tests/test-results/gcc-14-c++2b/pure2-range-operators.cpp.execution b/regression-tests/test-results/gcc-14-c++2b/pure2-range-operators.cpp.execution index df04174c1..100e0a464 100644 --- a/regression-tests/test-results/gcc-14-c++2b/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/gcc-14-c++2b/pure2-range-operators.cpp.execution @@ -15,6 +15,16 @@ And from indexes 1..=5 they are: 4 Elephant 5 Flicker +And test the range when mixing signed & unsigned types: + 0 Aardvark + 1 Baboon + 2 Cat + 3 Dolphin + 4 Elephant + 5 Flicker + 6 Grue + 7 Wumpus + Make sure non-random-access iterators work: Hokey Pokey @@ -34,6 +44,3 @@ true true false false - -Make sure views::take works: -1 2 3 4 5 2 3 4 \ No newline at end of file diff --git a/regression-tests/test-results/msvc-2022-c++20/pure2-assert-expected-not-null.cpp.output b/regression-tests/test-results/msvc-2022-c++20/pure2-assert-expected-not-null.cpp.output index c953444d7..5e8348010 100644 --- a/regression-tests/test-results/msvc-2022-c++20/pure2-assert-expected-not-null.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++20/pure2-assert-expected-not-null.cpp.output @@ -6,7 +6,7 @@ pure2-assert-expected-not-null.cpp2(7): error C2143: syntax error: missing ';' b pure2-assert-expected-not-null.cpp2(7): error C2143: syntax error: missing ';' before '}' pure2-assert-expected-not-null.cpp2(9): error C2065: 'ex': undeclared identifier pure2-assert-expected-not-null.cpp2(9): error C2672: 'cpp2::impl::assert_not_null': no matching overloaded function found -..\..\..\include\cpp2util.h(994): note: could be 'decltype(auto) cpp2::impl::assert_not_null(_T0 &&,std::source_location)' +..\..\..\include\cpp2util.h(999): note: could be 'decltype(auto) cpp2::impl::assert_not_null(_T0 &&,std::source_location)' pure2-assert-expected-not-null.cpp2(14): error C2039: 'expected': is not a member of 'std' predefined C++ types (compiler internal)(347): note: see declaration of 'std' pure2-assert-expected-not-null.cpp2(14): error C2062: type 'int' unexpected @@ -14,9 +14,9 @@ pure2-assert-expected-not-null.cpp2(14): error C2143: syntax error: missing ';' pure2-assert-expected-not-null.cpp2(14): error C2039: 'unexpected': is not a member of 'std' predefined C++ types (compiler internal)(347): note: see declaration of 'std' pure2-assert-expected-not-null.cpp2(14): error C2660: 'unexpected': function does not take 1 arguments -C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.40.33807\include\eh.h(33): note: see declaration of 'unexpected' +C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.41.34120\include\eh.h(33): note: see declaration of 'unexpected' pure2-assert-expected-not-null.cpp2(14): note: while trying to match the argument list '(bool)' pure2-assert-expected-not-null.cpp2(14): error C2143: syntax error: missing ';' before '}' pure2-assert-expected-not-null.cpp2(15): error C2065: 'ex': undeclared identifier pure2-assert-expected-not-null.cpp2(15): error C2672: 'cpp2::impl::assert_not_null': no matching overloaded function found -..\..\..\include\cpp2util.h(994): note: could be 'decltype(auto) cpp2::impl::assert_not_null(_T0 &&,std::source_location)' +..\..\..\include\cpp2util.h(999): note: could be 'decltype(auto) cpp2::impl::assert_not_null(_T0 &&,std::source_location)' diff --git a/regression-tests/test-results/msvc-2022-c++20/pure2-last-use.cpp.output b/regression-tests/test-results/msvc-2022-c++20/pure2-last-use.cpp.output index 79703bb60..09c3c8f64 100644 --- a/regression-tests/test-results/msvc-2022-c++20/pure2-last-use.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++20/pure2-last-use.cpp.output @@ -1 +1,13 @@ pure2-last-use.cpp +pure2-last-use.cpp2(274): error C2039: 'move_only_function': is not a member of 'std' +predefined C++ types (compiler internal)(347): note: see declaration of 'std' +pure2-last-use.cpp2(274): error C7568: argument list missing after assumed function template 'move_only_function' +pure2-last-use.cpp2(274): error C2062: type 'unknown-type' unexpected +pure2-last-use.cpp2(274): error C2238: unexpected token(s) preceding ';' +pure2-last-use.cpp2(275): error C2039: 'move_only_function': is not a member of 'std' +predefined C++ types (compiler internal)(347): note: see declaration of 'std' +pure2-last-use.cpp2(275): error C7568: argument list missing after assumed function template 'move_only_function' +pure2-last-use.cpp2(275): error C2062: type 'unknown-type' unexpected +pure2-last-use.cpp2(275): error C2238: unexpected token(s) preceding ';' +pure2-last-use.cpp2(277): error C2760: syntax error: '>' was unexpected here; expected 'expression' +pure2-last-use.cpp2(276): fatal error C1907: unable to recover from previous error(s); stopping compilation diff --git a/regression-tests/test-results/msvc-2022-c++20/pure2-range-operators.cpp.execution b/regression-tests/test-results/msvc-2022-c++20/pure2-range-operators.cpp.execution index df04174c1..9937f85c3 100644 --- a/regression-tests/test-results/msvc-2022-c++20/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/msvc-2022-c++20/pure2-range-operators.cpp.execution @@ -15,6 +15,16 @@ And from indexes 1..=5 they are: 4 Elephant 5 Flicker +And test the range when mixing signed & unsigned types: + 0 Aardvark + 1 Baboon + 2 Cat + 3 Dolphin + 4 Elephant + 5 Flicker + 6 Grue + 7 Wumpus + Make sure non-random-access iterators work: Hokey Pokey diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-range-operators.cpp.execution b/regression-tests/test-results/msvc-2022-c++latest/pure2-range-operators.cpp.execution index df04174c1..9937f85c3 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-range-operators.cpp.execution @@ -15,6 +15,16 @@ And from indexes 1..=5 they are: 4 Elephant 5 Flicker +And test the range when mixing signed & unsigned types: + 0 Aardvark + 1 Baboon + 2 Cat + 3 Dolphin + 4 Elephant + 5 Flicker + 6 Grue + 7 Wumpus + Make sure non-random-access iterators work: Hokey Pokey diff --git a/regression-tests/test-results/pure2-range-operators.cpp b/regression-tests/test-results/pure2-range-operators.cpp index 8a3ece53b..53ef35a57 100644 --- a/regression-tests/test-results/pure2-range-operators.cpp +++ b/regression-tests/test-results/pure2-range-operators.cpp @@ -35,6 +35,11 @@ auto main() -> int{ std::cout << " " + cpp2::to_string(e) + " " + cpp2::to_string(CPP2_ASSERT_IN_BOUNDS(v, e)) + "\n"; } + std::cout << "\nAnd test the range when mixing signed & unsigned types:\n"; + for ( auto const& e : cpp2::range(0,CPP2_UFCS(size)(v)) ) { + std::cout << " " + cpp2::to_string(e) + " " + cpp2::to_string(CPP2_ASSERT_IN_BOUNDS(v, e)) + "\n"; + } + std::list all_about { "Hokey", "Pokey"}; From 919e5bcd8126d3dcd0359db357e72c7329b4e249 Mon Sep 17 00:00:00 2001 From: Neil Henderson Date: Wed, 4 Sep 2024 10:21:23 +1000 Subject: [PATCH 2/3] Update regression tests due to line number changes --- .../pure2-default-arguments.cpp.output | 52 +++++++++---------- ...mixed-bugfix-for-ufcs-non-local.cpp.output | 20 +++---- ...mixed-bugfix-for-ufcs-non-local.cpp.output | 20 +++---- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/regression-tests/test-results/gcc-10-c++20/pure2-default-arguments.cpp.output b/regression-tests/test-results/gcc-10-c++20/pure2-default-arguments.cpp.output index b6358b20c..f58ffed21 100644 --- a/regression-tests/test-results/gcc-10-c++20/pure2-default-arguments.cpp.output +++ b/regression-tests/test-results/gcc-10-c++20/pure2-default-arguments.cpp.output @@ -1,66 +1,66 @@ In file included from pure2-default-arguments.cpp:7: ../../../include/cpp2util.h:2086:28: error: local variable ‘obj’ may not appear in this context - 2086 | template X> - | ^~~ + 2086 | // std::any is and as + | ^ ../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’ - 2047 | return false; - | ^ + 2047 | return std::get_if(&x) != nullptr; + | ^~~~~~~~~~~ ../../../include/cpp2util.h:2086:15: note: in expansion of macro ‘CPP2_FORWARD’ - 2086 | template X> - | ^~~~~~~~~~~~ + 2086 | // std::any is and as + | ^~~~~~~~ ../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’ - 2107 | } + 2107 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ ../../../include/cpp2util.h:2086:92: error: local variable ‘params’ may not appear in this context - 2086 | template X> + 2086 | // std::any is and as | ^ ../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’ - 2047 | return false; - | ^ + 2047 | return std::get_if(&x) != nullptr; + | ^~~~~~~~~~~ ../../../include/cpp2util.h:2086:79: note: in expansion of macro ‘CPP2_FORWARD’ - 2086 | template X> + 2086 | // std::any is and as | ^ ../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’ - 2107 | } + 2107 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ ../../../include/cpp2util.h:2087:74: error: local variable ‘obj’ may not appear in this context - 2087 | constexpr auto is( X const& x ) -> bool{ + 2087 | // | ^ ../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’ - 2047 | return false; - | ^ + 2047 | return std::get_if(&x) != nullptr; + | ^~~~~~~~~~~ ../../../include/cpp2util.h:2087:61: note: in expansion of macro ‘CPP2_FORWARD’ - 2087 | constexpr auto is( X const& x ) -> bool{ + 2087 | // | ^ ../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’ - 2107 | } + 2107 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ ../../../include/cpp2util.h:2087:93: error: local variable ‘params’ may not appear in this context - 2087 | constexpr auto is( X const& x ) -> bool{ + 2087 | // | ^ ../../../include/cpp2util.h:2047:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’ - 2047 | return false; - | ^ + 2047 | return std::get_if(&x) != nullptr; + | ^~~~~~~~~~~ ../../../include/cpp2util.h:2087:80: note: in expansion of macro ‘CPP2_FORWARD’ - 2087 | constexpr auto is( X const& x ) -> bool{ + 2087 | // | ^ ../../../include/cpp2util.h:2107:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’ - 2107 | } + 2107 | | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ pure2-default-arguments.cpp2:6:61: error: ‘std::source_location’ has not been declared diff --git a/regression-tests/test-results/gcc-13-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output b/regression-tests/test-results/gcc-13-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output index 20b01c343..dc9d6f979 100644 --- a/regression-tests/test-results/gcc-13-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output +++ b/regression-tests/test-results/gcc-13-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output @@ -1,41 +1,41 @@ In file included from mixed-bugfix-for-ufcs-non-local.cpp:6: ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | return value(x); + 2100 | // | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ mixed-bugfix-for-ufcs-non-local.cpp2:13:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:13:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | return value(x); + 2100 | // | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | return value(x); + 2100 | // | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ mixed-bugfix-for-ufcs-non-local.cpp2:31:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:31:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | return value(x); + 2100 | // | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ mixed-bugfix-for-ufcs-non-local.cpp2:33:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:33:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | return value(x); + 2100 | // | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid diff --git a/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output b/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output index 20b01c343..dc9d6f979 100644 --- a/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output +++ b/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output @@ -1,41 +1,41 @@ In file included from mixed-bugfix-for-ufcs-non-local.cpp:6: ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | return value(x); + 2100 | // | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ mixed-bugfix-for-ufcs-non-local.cpp2:13:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:13:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | return value(x); + 2100 | // | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | return value(x); + 2100 | // | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ mixed-bugfix-for-ufcs-non-local.cpp2:31:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:31:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | return value(x); + 2100 | // | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ mixed-bugfix-for-ufcs-non-local.cpp2:33:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:33:36: error: template argument 1 is invalid ../../../include/cpp2util.h:2100:1: error: lambda-expression in template parameter type - 2100 | return value(x); + 2100 | // | ^ ../../../include/cpp2util.h:2137:59: note: in expansion of macro ‘CPP2_UFCS_’ - 2137 | return false; + 2137 | return std::same_as; | ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid From af3b12e45b84131e4da896ca3f79fd5eb2b7383a Mon Sep 17 00:00:00 2001 From: Herb Sutter Date: Mon, 23 Sep 2024 12:47:06 -1000 Subject: [PATCH 3/3] Merge results of rerunning regression on my machine --- .../gcc-14-c++2b/pure2-default-arguments.cpp.execution | 2 +- .../gcc-14-c++2b/pure2-range-operators.cpp.execution | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/regression-tests/test-results/gcc-14-c++2b/pure2-default-arguments.cpp.execution b/regression-tests/test-results/gcc-14-c++2b/pure2-default-arguments.cpp.execution index afb167feb..0d1459552 100644 --- a/regression-tests/test-results/gcc-14-c++2b/pure2-default-arguments.cpp.execution +++ b/regression-tests/test-results/gcc-14-c++2b/pure2-default-arguments.cpp.execution @@ -1,4 +1,4 @@ calling: int main(int, char**) 012 -an older compiler +a newer compiler 1, 1, 66 diff --git a/regression-tests/test-results/gcc-14-c++2b/pure2-range-operators.cpp.execution b/regression-tests/test-results/gcc-14-c++2b/pure2-range-operators.cpp.execution index 100e0a464..9937f85c3 100644 --- a/regression-tests/test-results/gcc-14-c++2b/pure2-range-operators.cpp.execution +++ b/regression-tests/test-results/gcc-14-c++2b/pure2-range-operators.cpp.execution @@ -44,3 +44,6 @@ true true false false + +Make sure views::take works: +1 2 3 4 5 2 3 4 \ No newline at end of file