From f0c35e6aff256f82cffb96d089dec84956f059ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Pr=C3=B6tel?= Date: Fri, 29 Dec 2023 19:18:34 +0100 Subject: [PATCH 1/9] Change new to return an optional of a owning_reference. After the initial test if the owning_reference is returned no further null_checks are necessary since the reference cannot be set to null. --- include/cpp2util.h | 21 ++++++- regression-tests/pure2-new-basics.cpp2 | 78 ++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 regression-tests/pure2-new-basics.cpp2 diff --git a/include/cpp2util.h b/include/cpp2util.h index 463dd994e..4f4d00a7f 100644 --- a/include/cpp2util.h +++ b/include/cpp2util.h @@ -612,8 +612,25 @@ struct { } inline shared; template -[[nodiscard]] auto cpp2_new(auto&& ...args) -> std::unique_ptr { - return unique.cpp2_new(CPP2_FORWARD(args)...); +class owning_reference { +public: + explicit owning_reference(std::unique_ptr&& ptr):_ptr(assert_not_null(std::move(ptr))){} + ~owning_reference() = default; + owning_reference(owning_reference&& ref) = default; + owning_reference& operator=(owning_reference&& ref) noexcept = default; + std::add_lvalue_reference::type operator*() const { return *assert_not_null(_ptr.get()); } + std::add_lvalue_reference::type operator->() const noexcept {return *assert_not_null(_ptr.get());} +private: + std::unique_ptr _ptr; +}; + +template +[[nodiscard]] auto cpp2_new(auto&& ...args) -> std::optional> { + auto _ptr = unique.cpp2_new(CPP2_FORWARD(args)...); + if (_ptr) { + return owning_reference{std::move(_ptr)}; + } + return {}; } diff --git a/regression-tests/pure2-new-basics.cpp2 b/regression-tests/pure2-new-basics.cpp2 new file mode 100644 index 000000000..e35abba99 --- /dev/null +++ b/regression-tests/pure2-new-basics.cpp2 @@ -0,0 +1,78 @@ +Movable : type = { + operator= : (out this) = {} + operator= : (out this, move that) = {} + test : (this) = {} +} + +Copyable : type = { + operator= : (out this) = {} + operator= : (out this, in that) = {} + test : (this) = {} +} + +call_test : (m : _) = { + m.test(); +} + +test_movable : () = { + a : Movable = (); + a.test(); + call_test(a); + + b : Movable = a; + b.test(); + call_test(b); + + //a.test(); // not allowed +} + +test_movable_ref : () = { + a : _ = new(); + + if (a) { + a**.test(); + call_test(a**); + //b : _ = a**; // cannot create copy + c : _ = a*; + call_test(c*); + c*.test(); + // a**.test(); // not allowed + } +} + +test_copyable : () = { + a : Copyable = (); + a.test(); + call_test(a); + + b : Copyable = a; + b.test(); + call_test(b); + + a.test(); // allowed +} + +test_copyable_ref : () = { + a : _ = new(); + + if (a) { + a**.test(); + call_test(a**); + b : _ = a**; // create copy + call_test(b); + b.test(); + a**.test(); // allowed + + c : _ = a*; // move owning reference from optional + call_test(c*); + c*.test(); + //a**.test(); // no longer allowed + } +} + +main: () = { + test_movable(); + test_movable_ref(); + test_copyable(); + test_copyable_ref(); +} From 54fc7e8dacd570ad4095ac1c48762867fe321891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Pr=C3=B6tel?= Date: Fri, 29 Dec 2023 19:25:26 +0100 Subject: [PATCH 2/9] Added replace tests. --- regression-tests/pure2-new-basics.cpp2 | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/regression-tests/pure2-new-basics.cpp2 b/regression-tests/pure2-new-basics.cpp2 index e35abba99..fb19ae6b9 100644 --- a/regression-tests/pure2-new-basics.cpp2 +++ b/regression-tests/pure2-new-basics.cpp2 @@ -40,6 +40,18 @@ test_movable_ref : () = { } } +test_movable_ref_replace : () = { + a : _ = new(); + if (a) { + a**.test(); + } + + a = new(); + if (a) { + a**.test(); + } +} + test_copyable : () = { a : Copyable = (); a.test(); @@ -70,9 +82,24 @@ test_copyable_ref : () = { } } +test_copyable_ref_replace : () = { + a : _ = new(); + if (a) { + a**.test(); + } + + a = new(); + if (a) { + a**.test(); + } +} + + main: () = { test_movable(); test_movable_ref(); + test_movable_ref_replace(); test_copyable(); test_copyable_ref(); + test_copyable_ref_replace(); } From 6383f0afebaf02d087d6a4d66521647f3a41a46d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Pr=C3=B6tel?= Date: Fri, 29 Dec 2023 19:46:39 +0100 Subject: [PATCH 3/9] Added 'typename' --- include/cpp2util.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/cpp2util.h b/include/cpp2util.h index 4f4d00a7f..d64e24f63 100644 --- a/include/cpp2util.h +++ b/include/cpp2util.h @@ -618,8 +618,8 @@ class owning_reference { ~owning_reference() = default; owning_reference(owning_reference&& ref) = default; owning_reference& operator=(owning_reference&& ref) noexcept = default; - std::add_lvalue_reference::type operator*() const { return *assert_not_null(_ptr.get()); } - std::add_lvalue_reference::type operator->() const noexcept {return *assert_not_null(_ptr.get());} + typename std::add_lvalue_reference::type operator*() const { return *assert_not_null(_ptr.get()); } + typename std::add_lvalue_reference::type operator->() const noexcept {return *assert_not_null(_ptr.get());} private: std::unique_ptr _ptr; }; From b9e9664c33f362453bd46c73774bff9b776a45cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Pr=C3=B6tel?= Date: Sat, 24 Feb 2024 15:01:16 +0100 Subject: [PATCH 4/9] Fixed some failing tests. --- include/cpp2util.h | 1 + regression-tests/mixed-type-safety-1.cpp2 | 2 +- regression-tests/pure2-last-use.cpp2 | 162 +++++++++++----------- 3 files changed, 83 insertions(+), 82 deletions(-) diff --git a/include/cpp2util.h b/include/cpp2util.h index c5f648ead..678a8a449 100644 --- a/include/cpp2util.h +++ b/include/cpp2util.h @@ -696,6 +696,7 @@ class owning_reference { owning_reference& operator=(owning_reference&& ref) noexcept = default; typename std::add_lvalue_reference::type operator*() const { return *assert_not_null(_ptr.get()); } typename std::add_lvalue_reference::type operator->() const noexcept {return *assert_not_null(_ptr.get());} + auto get() const noexcept { return _ptr.get();} private: std::unique_ptr _ptr; }; diff --git a/regression-tests/mixed-type-safety-1.cpp2 b/regression-tests/mixed-type-safety-1.cpp2 index d7fb8adf9..1fc22dfa3 100644 --- a/regression-tests/mixed-type-safety-1.cpp2 +++ b/regression-tests/mixed-type-safety-1.cpp2 @@ -29,7 +29,7 @@ main: () -> int = print( "1 is int? ", 1 is int ); c := new(); // safe by construction - s : * Shape = c.get(); // safe by Lifetime + s : * Shape = c*.get(); // safe by Lifetime print("\ns* is Shape? ", s* is Shape ); print( "s* is Circle? ", s* is Circle ); print( "s* is Square? ", s* is Square ); diff --git a/regression-tests/pure2-last-use.cpp2 b/regression-tests/pure2-last-use.cpp2 index d924b777d..abf1b8ae1 100644 --- a/regression-tests/pure2-last-use.cpp2 +++ b/regression-tests/pure2-last-use.cpp2 @@ -7,57 +7,57 @@ identity_copy: (copy x) x; issue_313: () = { _ = :() -> std::vector = { - a := new(0); + a := new(0)*; return (a*, identity_copy(a)*); }; _ = :() -> std::vector = { - a := new(0); + a := new(0)*; return (a&**, identity_copy(a)*); }; _ = :() -> int = { - a := new(0); + a := new(0)*; return identity(a)* + identity(a)*; - b := new(0); + b := new(0)*; return identity(b)* = identity(b)*; - c := new(0); + c := new(0)*; return identity(c)* ^ identity(c)*; }; { - a := new(0); + a := new(0)*; identity(a)* = identity(a)*; - b := new(0); + b := new(0)*; _: int = identity(b)* = identity(b)*; - c := new(0); + c := new(0)*; if identity(c)* * identity(c)* { } - d := new(0); + d := new(0)*; if (identity(d)* - identity(d)*) { } - e := new(0); + e := new(0)*; _ = e is (e); - f := new(0); + f := new(0)*; _ = f is std::type_identity_t; // OK? - g := new(0); + g := new(0)*; for (identity(g)* + identity(g)*) do (_) { } - h := new(0); + h := new(0)*; while identity(h)* + identity(h)* { } - i := new(0); + i := new(0)*; do { } while identity(i)* + identity(i)*; - j := new(0); - k := new(0); + j := new(0)*; + k := new(0)*; _ = inspect identity(j)* + identity(j)* -> int { is (identity(k)* + identity(k)*) = 0; is _ = 0; @@ -65,7 +65,7 @@ issue_313: () = { } { - a := new(0); + a := new(0)*; _ = :() identity(a$)* + identity(a$)*; } } @@ -113,7 +113,7 @@ issue_683: (args) = { issue_825: () = { _ = :(copy b: std::unique_ptr) f_copy(b); _ = :(move c: std::unique_ptr) f_copy(c); - _ = :(forward d) f_copy(d);(new(0)); + _ = :(forward d) f_copy(d);(new(0)*); } issue_832: () = { @@ -369,16 +369,16 @@ issue_857_9: @struct type = { } issue_869_0: @value type = { - operator=: (out this, move _: std::unique_ptr) = { } + operator=: (out this, move _: cpp2::owning_reference) = { } } issue_869_1: @union type = { i: issue_869_0; } -issue_869_2: () -> (res: issue_869_1 = ()) = { res.set_i(new(0)); } +issue_869_2: () -> (res: issue_869_1 = ()) = { res.set_i(new(0)*); } issue_884: () = { _ = :() = { - x := new(0); + x := new(0)*; if true { } { { f_inout(x); } @@ -387,7 +387,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_copy(x); } @@ -398,7 +398,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_inout(x); } @@ -410,7 +410,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_copy(x); if true { _ = 0; @@ -423,7 +423,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_copy(x); @@ -436,7 +436,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { _ = 0; @@ -449,7 +449,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { _ = 0; @@ -462,7 +462,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { _ = 0; @@ -475,7 +475,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_copy(x); @@ -488,7 +488,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_copy(x); @@ -501,7 +501,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_inout(x); @@ -517,7 +517,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_inout(x); @@ -533,7 +533,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_copy(x); @@ -549,7 +549,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { if true { if true { @@ -562,7 +562,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { if true { if true { @@ -576,7 +576,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { } else { @@ -589,7 +589,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_copy(x); } @@ -603,9 +603,9 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { - y := new(0); + y := new(0)*; f_copy(x); f_copy(y); } @@ -620,9 +620,9 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { - y := new(0); + y := new(0)*; if true { } else { f_copy(x); @@ -632,7 +632,7 @@ issue_884: () = { else { if true { if true { - y := new(0); + y := new(0)*; f_copy(y); f_inout(x); } @@ -642,9 +642,9 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { - y := new(0); + y := new(0)*; if true { } else { f_copy(x); @@ -652,7 +652,7 @@ issue_884: () = { } } else { - y := new(0); + y := new(0)*; if true { if true { f_copy(x); @@ -666,13 +666,13 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_copy(x); } else { if true { - x := new(0); + x := new(0)*; if true { f_inout(x); } @@ -685,10 +685,10 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { if true { - x := new(0); + x := new(0)*; if true { f_inout(x); } @@ -704,7 +704,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_inout(x); @@ -718,7 +718,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { if true { f_inout(x); @@ -781,9 +781,9 @@ issue_888_1: (copy _: std::string, copy size: move_only_function) = { } issue_890: () = { - x := new(0); + x := new(0)*; assert(identity_copy(x)* == 0); - (x := new(0)) assert(identity(x)* == 0); + (x := new(0)*) assert(identity(x)* == 0); } issue_962: (s: ::std::string) = { @@ -803,13 +803,13 @@ enum_0: () = { underlying_type = ""; } enum_1: () = { - max_value := new(0); - min_value: std::reference_wrapper> = max_value; + max_value := new(0)*; + min_value: std::reference_wrapper> = max_value; for (0) do (copy x) { - v := new(identity_copy(x)); + v := new(identity_copy(x))*; if pred(v, min_value) { min_value = std::ref(identity(v)); // Not using 'else' will never move 'v'. } @@ -818,20 +818,20 @@ enum_1: () = { } } - y := new(false); + y := new(false)*; while identity(y)* { - v := new(0); + v := new(0)*; f_copy(v); } - z := new(false); + z := new(false)*; do { - v := new(0); + v := new(0)*; f_copy(v); } while identity(z)*; } enum_2: () = { - umax := new(0); + umax := new(0)*; if pred(umax) { } else if pred(umax) { @@ -873,14 +873,14 @@ deferred_non_copyable_2: () -> (p: std::unique_ptr) = { loops: () = { _ = :() = { - x := new(0); + x := new(0)*; for (0) do (_) f_inout(x); }; _ = :() = { - x := new(0); + x := new(0)*; for (0) next f_inout(x) do (_) @@ -888,14 +888,14 @@ loops: () = { }; _ = :() = { - x := new(0); + x := new(0)*; for (0) do (_) assert(x.get()); }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_copy(x); } @@ -912,10 +912,10 @@ captures: namespace = { // Skip non captured name in function expression f: () = { - x := new(0); + x := new(0)*; f_copy(x); id := :(x) -> forward _ = x; - y := new(0); + y := new(0)*; assert(id(y)& == y&); } @@ -938,13 +938,13 @@ t: @struct type = { g: () = { _ = :() = { - x := new(0); + x := new(0)*; f_copy(x); _ = :() std::array()$; // Fails on Clang 12 (lambda in unevaluated context). }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); _ = :() -> int = (:() x$*)$(); }; @@ -954,7 +954,7 @@ g: () = { loops_and_captures: () = { _ = :() = { - x := new(0); + x := new(0)*; f_copy(x); for (:(x) x) do (_) @@ -962,7 +962,7 @@ loops_and_captures: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_copy(x); for (:() -> _ = { using captures::x; @@ -973,7 +973,7 @@ loops_and_captures: () = { }; _ = :() = { - x := new(0); + x := new(0)*; for (:() x$*) do (_) { } @@ -992,17 +992,17 @@ types: @struct type = { skip_hidden_names: () = { _ = :() = { - x := new(0); + x := new(0)*; f_copy(x); - (copy x := new(0)) + (copy x := new(0)*) f_copy(x); }; _ = :() = { - x := new(0); + x := new(0)*; _ = :() = { _ = x$; - x := new(1); + x := new(1)*; _ = :() = { _ = x$; }; @@ -1010,17 +1010,17 @@ skip_hidden_names: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_copy(x); for (0) do (copy x) _ = identity_copy(x); - (copy x := new(0)) + (copy x := new(0)*) f_copy(x); }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); { f_copy(x); @@ -1030,10 +1030,10 @@ skip_hidden_names: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_copy(x); _ = :() = { - static_assert(std::is_same_v>); + static_assert(std::is_same_v>); using captures::x; f_inout(x); }; From 2e7d80297f6882bbd02000cb162ca740ba7e30d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Pr=C3=B6tel?= Date: Sat, 24 Feb 2024 15:50:42 +0100 Subject: [PATCH 5/9] Adjusted expected test files --- .../test-results/pure2-last-use.cpp | 170 +++++++-------- .../test-results/pure2-new-basics.cpp | 194 ++++++++++++++++++ .../test-results/pure2-new-basics.cpp2.output | 2 + 3 files changed, 281 insertions(+), 85 deletions(-) create mode 100644 regression-tests/test-results/pure2-new-basics.cpp create mode 100644 regression-tests/test-results/pure2-new-basics.cpp2.output diff --git a/regression-tests/test-results/pure2-last-use.cpp b/regression-tests/test-results/pure2-last-use.cpp index f8352a476..9fcad4279 100644 --- a/regression-tests/test-results/pure2-last-use.cpp +++ b/regression-tests/test-results/pure2-last-use.cpp @@ -287,9 +287,9 @@ class issue_857_9: public issue_857_8 { }; class issue_869_0 { - public: explicit issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2); + public: explicit issue_869_0([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2); #line 372 "pure2-last-use.cpp2" - public: auto operator=([[maybe_unused]] std::unique_ptr&& unnamed_param_2) -> issue_869_0& ; + public: auto operator=([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2) -> issue_869_0& ; public: [[nodiscard]] auto operator<=>([[maybe_unused]] issue_869_0 const& that) const& -> std::strong_ordering = default; public: issue_869_0([[maybe_unused]] issue_869_0 const& that); @@ -439,57 +439,57 @@ requires (std::is_reference_v) {return CPP2_FORWARD(x); } #line 8 "pure2-last-use.cpp2" auto issue_313() -> void{ static_cast([]() mutable -> std::vector{ - auto a {cpp2_new(0)}; + auto a {*cpp2::assert_not_null(cpp2_new(0))}; return { *cpp2::assert_not_null(a), *cpp2::assert_not_null(identity_copy(std::move(a))) }; }); static_cast([]() mutable -> std::vector{ - auto a {cpp2_new(0)}; + auto a {*cpp2::assert_not_null(cpp2_new(0))}; return { *cpp2::assert_not_null(*cpp2::assert_not_null(&a)), *cpp2::assert_not_null(identity_copy(std::move(a))) }; }); static_cast([]() mutable -> int{ - auto a {cpp2_new(0)}; + auto a {*cpp2::assert_not_null(cpp2_new(0))}; return *cpp2::assert_not_null(identity(a)) + *cpp2::assert_not_null(identity(a)); - auto b {cpp2_new(0)}; + auto b {*cpp2::assert_not_null(cpp2_new(0))}; return *cpp2::assert_not_null(identity(b)) = *cpp2::assert_not_null(identity(b)); - auto c {cpp2_new(0)}; + auto c {*cpp2::assert_not_null(cpp2_new(0))}; return *cpp2::assert_not_null(identity(c)) ^ *cpp2::assert_not_null(identity(c)); }); { - auto a {cpp2_new(0)}; + auto a {*cpp2::assert_not_null(cpp2_new(0))}; *cpp2::assert_not_null(identity(a)) = *cpp2::assert_not_null(identity(a)); - auto b {cpp2_new(0)}; + auto b {*cpp2::assert_not_null(cpp2_new(0))}; int auto_1 {*cpp2::assert_not_null(identity(b)) = *cpp2::assert_not_null(identity(b))}; - auto c {cpp2_new(0)}; + auto c {*cpp2::assert_not_null(cpp2_new(0))}; if (*cpp2::assert_not_null(identity(c)) * *cpp2::assert_not_null(identity(c))) {} - auto d {cpp2_new(0)}; + auto d {*cpp2::assert_not_null(cpp2_new(0))}; if ((*cpp2::assert_not_null(identity(d)) - *cpp2::assert_not_null(identity(d)))) {} - auto e {cpp2_new(0)}; + auto e {*cpp2::assert_not_null(cpp2_new(0))}; static_cast(cpp2::is(e, (e))); - auto f {cpp2_new(0)}; + auto f {*cpp2::assert_not_null(cpp2_new(0))}; static_cast(cpp2::is>(f));// OK? - auto g {cpp2_new(0)}; + auto g {*cpp2::assert_not_null(cpp2_new(0))}; for ( [[maybe_unused]] auto const& unnamed_param_1 : { *cpp2::assert_not_null(identity(g)) + *cpp2::assert_not_null(identity(g)) } ) {} - auto h {cpp2_new(0)}; + auto h {*cpp2::assert_not_null(cpp2_new(0))}; while( *cpp2::assert_not_null(identity(h)) + *cpp2::assert_not_null(identity(h)) ) {} - auto i {cpp2_new(0)}; + auto i {*cpp2::assert_not_null(cpp2_new(0))}; do {} while ( *cpp2::assert_not_null(identity(i)) + *cpp2::assert_not_null(identity(i))); - auto j {cpp2_new(0)}; - auto k {cpp2_new(0)}; + auto j {*cpp2::assert_not_null(cpp2_new(0))}; + auto k {*cpp2::assert_not_null(cpp2_new(0))}; static_cast([&] () -> int { auto&& _expr = *cpp2::assert_not_null(identity(j)) + *cpp2::assert_not_null(identity(j)); if (cpp2::is(_expr, (*cpp2::assert_not_null(identity(k)) + *cpp2::assert_not_null(identity(k))))) { if constexpr( requires{0;} ) if constexpr( std::is_convertible_v ) return 0; else return int{}; else return int{}; } else return 0; } @@ -497,7 +497,7 @@ auto issue_313() -> void{ } { - auto a {cpp2_new(0)}; + auto a {*cpp2::assert_not_null(cpp2_new(0))}; static_cast([_0 = std::move(a)]() mutable -> auto { return *cpp2::assert_not_null(identity(_0)) + *cpp2::assert_not_null(identity(_0)); }); } } @@ -532,7 +532,7 @@ auto issue_683(auto const& args) -> void{ auto issue_825() -> void{ static_cast([](std::unique_ptr b) mutable -> auto { return f_copy(std::move(b)); }); static_cast([](std::unique_ptr&& c) mutable -> auto { return f_copy(std::move(c)); }); - static_cast([](auto&& d) mutable -> auto { return f_copy(CPP2_FORWARD(d)); }(cpp2_new(0))); + static_cast([](auto&& d) mutable -> auto { return f_copy(CPP2_FORWARD(d)); }(*cpp2::assert_not_null(cpp2_new(0)))); } #line 119 "pure2-last-use.cpp2" @@ -818,10 +818,10 @@ int gi {0}; auto issue_857_9::g3() && -> void { CPP2_UFCS(d)(std::move((*this))); } #line 372 "pure2-last-use.cpp2" - issue_869_0::issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2){} + issue_869_0::issue_869_0([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2){} #line 372 "pure2-last-use.cpp2" - auto issue_869_0::operator=([[maybe_unused]] std::unique_ptr&& unnamed_param_2) -> issue_869_0& { - return *this; } + auto issue_869_0::operator=([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2) -> issue_869_0& { + return *this; } issue_869_0::issue_869_0([[maybe_unused]] issue_869_0 const& that){} @@ -869,13 +869,13 @@ issue_869_1::issue_869_1(issue_869_1 const& that) } #line 377 "pure2-last-use.cpp2" [[nodiscard]] auto issue_869_2() -> issue_869_2_ret{ - issue_869_1 res {}; CPP2_UFCS(set_i)(res, cpp2_new(0)); + issue_869_1 res {}; CPP2_UFCS(set_i)(res, *cpp2::assert_not_null(cpp2_new(0))); #line 378 "pure2-last-use.cpp2" return res; } #line 379 "pure2-last-use.cpp2" auto issue_884() -> void{ static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) {} { {f_inout(x); } @@ -884,7 +884,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { f_copy(std::move(x)); } @@ -895,7 +895,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { f_inout(x); } @@ -907,7 +907,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(x)); if (true) { static_cast(0); @@ -920,7 +920,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_copy(std::move(x)); @@ -933,7 +933,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { static_cast(0); @@ -946,7 +946,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { static_cast(0); @@ -959,7 +959,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { static_cast(0); @@ -972,7 +972,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_copy(std::move(x)); @@ -985,7 +985,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_copy(std::move(x)); @@ -998,7 +998,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_inout(x); @@ -1014,7 +1014,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_inout(x); @@ -1030,7 +1030,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_copy(std::move(x)); @@ -1046,7 +1046,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { if (true) { if (true) { @@ -1059,7 +1059,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { if (true) { if (true) { @@ -1073,7 +1073,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { } else { @@ -1086,7 +1086,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { f_copy(std::move(x)); } @@ -1100,9 +1100,9 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { - auto y {cpp2_new(0)}; + auto y {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(x)); f_copy(std::move(y)); } @@ -1117,9 +1117,9 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { - auto y {cpp2_new(0)}; + auto y {*cpp2::assert_not_null(cpp2_new(0))}; if (true) {} else { f_copy(std::move(x)); @@ -1129,7 +1129,7 @@ auto issue_884() -> void{ else { if (true) { if (true) { - auto y {cpp2_new(0)}; + auto y {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(y)); f_inout(x); } @@ -1139,9 +1139,9 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { - auto y {cpp2_new(0)}; + auto y {*cpp2::assert_not_null(cpp2_new(0))}; if (true) {} else { f_copy(std::move(x)); @@ -1149,7 +1149,7 @@ auto issue_884() -> void{ } } else { - auto y {cpp2_new(0)}; + auto y {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { if (true) { f_copy(std::move(x)); @@ -1163,13 +1163,13 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { f_copy(std::move(x)); } else { if (true) { - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { f_inout(x); } @@ -1182,10 +1182,10 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { if (true) { - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { f_inout(x); } @@ -1201,7 +1201,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { f_inout(x); @@ -1215,7 +1215,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { if (true) { f_inout(x); @@ -1281,10 +1281,10 @@ auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, move_only_functio #line 783 "pure2-last-use.cpp2" auto issue_890() -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (cpp2::Default.has_handler() && !(*cpp2::assert_not_null(identity_copy(std::move(x))) == 0) ) { cpp2::Default.report_violation(""); } { -auto const& x{cpp2_new(0)}; +auto const& x{*cpp2::assert_not_null(cpp2_new(0))}; #line 786 "pure2-last-use.cpp2" if (cpp2::Default.has_handler() && !(*cpp2::assert_not_null(identity(x)) == 0) ) { cpp2::Default.report_violation(""); } } @@ -1312,13 +1312,13 @@ auto enum_0() -> void{ } #line 805 "pure2-last-use.cpp2" auto enum_1() -> void{ - auto max_value {cpp2_new(0)}; - std::reference_wrapper const> min_value {max_value}; + auto max_value {*cpp2::assert_not_null(cpp2_new(0))}; + std::reference_wrapper const> min_value {max_value}; for ( auto x : { 0 } ) { - auto v {cpp2_new(identity_copy(std::move(x)))}; + auto v {*cpp2::assert_not_null(cpp2_new(identity_copy(std::move(x))))}; if (pred(v, min_value)) { min_value = std::ref(identity(v)); // Not using 'else' will never move 'v'. } @@ -1327,21 +1327,21 @@ auto enum_1() -> void{ } } - auto y {cpp2_new(false)}; + auto y {*cpp2::assert_not_null(cpp2_new(false))}; while( *cpp2::assert_not_null(identity(y)) ) { - auto v {cpp2_new(0)}; + auto v {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(v)); } - auto z {cpp2_new(false)}; + auto z {*cpp2::assert_not_null(cpp2_new(false))}; do { - auto v {cpp2_new(0)}; + auto v {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(v)); } while ( *cpp2::assert_not_null(identity(z))); } #line 833 "pure2-last-use.cpp2" auto enum_2() -> void{ - auto umax {cpp2_new(0)}; + auto umax {*cpp2::assert_not_null(cpp2_new(0))}; if (pred(umax)) { } else {if (pred(umax)) { @@ -1387,14 +1387,14 @@ return std::move(p.value()); } #line 874 "pure2-last-use.cpp2" auto loops() -> void{ static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; for ( [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) f_inout(x); }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; for ( [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) { do @@ -1402,14 +1402,14 @@ auto loops() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; for ( [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) if (cpp2::Default.has_handler() && !(CPP2_UFCS(get)(x)) ) { cpp2::Default.report_violation(""); } }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; if (true) { f_copy(std::move(x)); } @@ -1425,10 +1425,10 @@ namespace captures { #line 914 "pure2-last-use.cpp2" auto f() -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(x)); auto id {[](auto const& x) mutable -> auto&& { return x; }}; - auto y {cpp2_new(0)}; + auto y {*cpp2::assert_not_null(cpp2_new(0))}; if (cpp2::Default.has_handler() && !(&std::move(id)(y) == &y) ) { cpp2::Default.report_violation(""); } } @@ -1448,13 +1448,13 @@ auto f() -> void{ #line 939 "pure2-last-use.cpp2" auto g() -> void{ static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(x)); static_cast([_0 = std::array auto { return identity(x); }(0)>()]() mutable -> auto { return _0; });// Fails on Clang 12 (lambda in unevaluated context). }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_inout(x); static_cast([_0 = ([_0 = std::move(x)]() mutable -> auto { return *cpp2::assert_not_null(_0); })]() mutable -> int { return _0(); }); }); @@ -1465,7 +1465,7 @@ auto g() -> void{ #line 955 "pure2-last-use.cpp2" auto loops_and_captures() -> void{ static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(x)); for ( [[maybe_unused]] auto const& unnamed_param_1 : { [](auto const& x) mutable -> auto { return x; } } ) @@ -1473,7 +1473,7 @@ auto loops_and_captures() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(x)); for ( @@ -1483,7 +1483,7 @@ auto loops_and_captures() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; for ( [[maybe_unused]] auto const& unnamed_param_1 : { [_0 = std::move(x)]() mutable -> auto { return *cpp2::assert_not_null(_0); } } ) {} @@ -1502,10 +1502,10 @@ auto loops_and_captures() -> void{ #line 993 "pure2-last-use.cpp2" auto skip_hidden_names() -> void{ static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(x)); { -auto x{cpp2_new(0)}; +auto x{*cpp2::assert_not_null(cpp2_new(0))}; #line 998 "pure2-last-use.cpp2" f_copy(std::move(x)); @@ -1514,10 +1514,10 @@ auto x{cpp2_new(0)}; }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; static_cast([_0 = std::move(x)]() mutable -> void{ static_cast(_0); - auto x {cpp2_new(1)}; + auto x {*cpp2::assert_not_null(cpp2_new(1))}; static_cast([_0 = std::move(x)]() mutable -> void{ static_cast(_0); }); @@ -1525,13 +1525,13 @@ auto x{cpp2_new(0)}; }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(x)); for ( auto x : { 0 } ) static_cast(identity_copy(std::move(x))); { -auto x{cpp2_new(0)}; +auto x{*cpp2::assert_not_null(cpp2_new(0))}; #line 1019 "pure2-last-use.cpp2" f_copy(std::move(x)); @@ -1540,7 +1540,7 @@ auto x{cpp2_new(0)}; }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_inout(x); { f_copy(std::move(x)); @@ -1550,10 +1550,10 @@ auto x{cpp2_new(0)}; }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::assert_not_null(cpp2_new(0))}; f_copy(std::move(x)); static_cast([]() mutable -> void{ - static_assert(std::is_same_v>); + static_assert(std::is_same_v>); using captures::x; f_inout(x); }); diff --git a/regression-tests/test-results/pure2-new-basics.cpp b/regression-tests/test-results/pure2-new-basics.cpp new file mode 100644 index 000000000..1e4edcc67 --- /dev/null +++ b/regression-tests/test-results/pure2-new-basics.cpp @@ -0,0 +1,194 @@ + +#define CPP2_IMPORT_STD Yes + +//=== Cpp2 type declarations ==================================================== + + +#include "cpp2util.h" + +#line 1 "pure2-new-basics.cpp2" +class Movable; +#line 2 "pure2-new-basics.cpp2" + + +#line 7 "pure2-new-basics.cpp2" +class Copyable; + + +//=== Cpp2 type definitions and function declarations =========================== + +#line 1 "pure2-new-basics.cpp2" +class Movable { +#line 2 "pure2-new-basics.cpp2" + public: explicit Movable(); + public: Movable([[maybe_unused]] Movable&& that) noexcept; +#line 3 "pure2-new-basics.cpp2" + public: auto operator=([[maybe_unused]] Movable&& that) noexcept -> Movable& ; + public: auto test() const& -> void; +}; + +class Copyable { + public: explicit Copyable(); + public: Copyable([[maybe_unused]] Copyable const& that); +#line 9 "pure2-new-basics.cpp2" + public: auto operator=([[maybe_unused]] Copyable const& that) -> Copyable& ; +#line 9 "pure2-new-basics.cpp2" + public: Copyable([[maybe_unused]] Copyable&& that) noexcept; +#line 9 "pure2-new-basics.cpp2" + public: auto operator=([[maybe_unused]] Copyable&& that) noexcept -> Copyable& ; + public: auto test() const& -> void; +}; + +auto call_test(auto const& m) -> void; + +#line 17 "pure2-new-basics.cpp2" +auto test_movable() -> void; + +#line 29 "pure2-new-basics.cpp2" +auto test_movable_ref() -> void; + +#line 43 "pure2-new-basics.cpp2" +auto test_movable_ref_replace() -> void; + +#line 55 "pure2-new-basics.cpp2" +auto test_copyable() -> void; + +#line 67 "pure2-new-basics.cpp2" +auto test_copyable_ref() -> void; + +#line 85 "pure2-new-basics.cpp2" +auto test_copyable_ref_replace() -> void; + +#line 98 "pure2-new-basics.cpp2" +auto main() -> int; + +//=== Cpp2 function definitions ================================================= + +#line 1 "pure2-new-basics.cpp2" + +#line 2 "pure2-new-basics.cpp2" + Movable::Movable(){} +#line 3 "pure2-new-basics.cpp2" + Movable::Movable([[maybe_unused]] Movable&& that) noexcept{} +#line 3 "pure2-new-basics.cpp2" + auto Movable::operator=([[maybe_unused]] Movable&& that) noexcept -> Movable& { + return *this; } +#line 4 "pure2-new-basics.cpp2" + auto Movable::test() const& -> void{} + +#line 8 "pure2-new-basics.cpp2" + Copyable::Copyable(){} +#line 9 "pure2-new-basics.cpp2" + Copyable::Copyable([[maybe_unused]] Copyable const& that){} +#line 9 "pure2-new-basics.cpp2" + auto Copyable::operator=([[maybe_unused]] Copyable const& that) -> Copyable& { + return *this; } +#line 9 "pure2-new-basics.cpp2" + Copyable::Copyable([[maybe_unused]] Copyable&& that) noexcept{} +#line 9 "pure2-new-basics.cpp2" + auto Copyable::operator=([[maybe_unused]] Copyable&& that) noexcept -> Copyable& { + return *this; } +#line 10 "pure2-new-basics.cpp2" + auto Copyable::test() const& -> void{} + +#line 13 "pure2-new-basics.cpp2" +auto call_test(auto const& m) -> void{ + CPP2_UFCS(test)(m); +} + +#line 17 "pure2-new-basics.cpp2" +auto test_movable() -> void{ + Movable a {}; + CPP2_UFCS(test)(a); + call_test(a); + + Movable b {std::move(a)}; + CPP2_UFCS(test)(b); + call_test(std::move(b)); + + //a.test(); // not allowed +} + +#line 29 "pure2-new-basics.cpp2" +auto test_movable_ref() -> void{ + auto a {cpp2_new()}; + + if ((a)) { + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); + call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); + //b : _ = a**; // cannot create copy + auto c {*cpp2::assert_not_null(std::move(a))}; + call_test(*cpp2::assert_not_null(c)); + CPP2_UFCS(test)((*cpp2::assert_not_null(std::move(c)))); + // a**.test(); // not allowed + } +} + +#line 43 "pure2-new-basics.cpp2" +auto test_movable_ref_replace() -> void{ + auto a {cpp2_new()}; + if ((a)) { + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); + } + + a = cpp2_new(); + if ((a)) { + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(std::move(a))))); + } +} + +#line 55 "pure2-new-basics.cpp2" +auto test_copyable() -> void{ + Copyable a {}; + CPP2_UFCS(test)(a); + call_test(a); + + Copyable b {a}; + CPP2_UFCS(test)(b); + call_test(std::move(b)); + + CPP2_UFCS(test)(std::move(a));// allowed +} + +#line 67 "pure2-new-basics.cpp2" +auto test_copyable_ref() -> void{ + auto a {cpp2_new()}; + + if ((a)) { + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); + call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); + auto b {*cpp2::assert_not_null(*cpp2::assert_not_null(a))}; // create copy + call_test(b); + CPP2_UFCS(test)(std::move(b)); + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a))));// allowed + + auto c {*cpp2::assert_not_null(std::move(a))}; // move owning reference from optional + call_test(*cpp2::assert_not_null(c)); + CPP2_UFCS(test)((*cpp2::assert_not_null(std::move(c)))); + //a**.test(); // no longer allowed + } +} + +#line 85 "pure2-new-basics.cpp2" +auto test_copyable_ref_replace() -> void{ + auto a {cpp2_new()}; + if ((a)) { + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); + } + + a = cpp2_new(); + if ((a)) { + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(std::move(a))))); + } +} + +#line 98 "pure2-new-basics.cpp2" +auto main() -> int{ + test_movable(); + test_movable_ref(); + test_movable_ref_replace(); + test_copyable(); + test_copyable_ref(); + test_copyable_ref_replace(); +} + diff --git a/regression-tests/test-results/pure2-new-basics.cpp2.output b/regression-tests/test-results/pure2-new-basics.cpp2.output new file mode 100644 index 000000000..1be264804 --- /dev/null +++ b/regression-tests/test-results/pure2-new-basics.cpp2.output @@ -0,0 +1,2 @@ +pure2-new-basics.cpp2... ok (all Cpp2, passes safety checks) + From d4bbc157af2e72767c87fa522fea128fe9bf00f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Pr=C3=B6tel?= Date: Sat, 24 Feb 2024 16:24:30 +0100 Subject: [PATCH 6/9] Fixed more expected files. --- regression-tests/pure2-intro-example-three-loops.cpp2 | 7 ++++++- .../test-results/gcc-10/pure2-new-basics.cpp.execution | 0 .../test-results/gcc-10/pure2-new-basics.cpp.output | 0 regression-tests/test-results/mixed-type-safety-1.cpp | 2 +- .../test-results/pure2-intro-example-three-loops.cpp | 9 +++++++-- 5 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 regression-tests/test-results/gcc-10/pure2-new-basics.cpp.execution create mode 100644 regression-tests/test-results/gcc-10/pure2-new-basics.cpp.output diff --git a/regression-tests/pure2-intro-example-three-loops.cpp2 b/regression-tests/pure2-intro-example-three-loops.cpp2 index aa51ea959..6a7e95177 100644 --- a/regression-tests/pure2-intro-example-three-loops.cpp2 +++ b/regression-tests/pure2-intro-example-three-loops.cpp2 @@ -12,7 +12,12 @@ main: () -> int = { ( "hello", "big", "world" ); view: std::span = words; - i := new(0); + p_i := new(0); + if (!p_i) { + return 1; + } + i := p_i*; + while i* < view.ssize() next i*++ { print( view[i*] ); } diff --git a/regression-tests/test-results/gcc-10/pure2-new-basics.cpp.execution b/regression-tests/test-results/gcc-10/pure2-new-basics.cpp.execution new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/gcc-10/pure2-new-basics.cpp.output b/regression-tests/test-results/gcc-10/pure2-new-basics.cpp.output new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/mixed-type-safety-1.cpp b/regression-tests/test-results/mixed-type-safety-1.cpp index 42805efca..fa69bb441 100644 --- a/regression-tests/test-results/mixed-type-safety-1.cpp +++ b/regression-tests/test-results/mixed-type-safety-1.cpp @@ -58,7 +58,7 @@ auto print(cpp2::in msg, cpp2::in b) -> void print( "1 is int? ", cpp2::is(1)); auto c {cpp2_new()}; // safe by construction - Shape* s {CPP2_UFCS(get)(std::move(c))}; // safe by Lifetime + Shape* s {CPP2_UFCS(get)((*cpp2::assert_not_null(std::move(c))))}; // safe by Lifetime print("\ns* is Shape? ", cpp2::is(*cpp2::assert_not_null(s))); print( "s* is Circle? ", cpp2::is(*cpp2::assert_not_null(s))); print( "s* is Square? ", cpp2::is(*cpp2::assert_not_null(std::move(s)))); diff --git a/regression-tests/test-results/pure2-intro-example-three-loops.cpp b/regression-tests/test-results/pure2-intro-example-three-loops.cpp index 5ad0a40d2..0f06d9b90 100644 --- a/regression-tests/test-results/pure2-intro-example-three-loops.cpp +++ b/regression-tests/test-results/pure2-intro-example-three-loops.cpp @@ -21,7 +21,7 @@ auto decorate_and_print(auto& thing) -> void; #line 10 "pure2-intro-example-three-loops.cpp2" [[nodiscard]] auto main() -> int; -#line 30 "pure2-intro-example-three-loops.cpp2" +#line 35 "pure2-intro-example-three-loops.cpp2" #line 1 "pure2-intro-example-three-loops.cpp2" @@ -45,7 +45,12 @@ auto decorate_and_print(auto& thing) -> void{ "hello", "big", "world"}; std::span view {words}; - auto i {cpp2_new(0)}; + auto p_i {cpp2_new(0)}; + if ((!(p_i))) { + return 1; + } + auto i {*cpp2::assert_not_null(std::move(p_i))}; + for( ; cpp2::cmp_less(*cpp2::assert_not_null(i),CPP2_UFCS(ssize)(view)); ++*cpp2::assert_not_null(i) ) { print(CPP2_ASSERT_IN_BOUNDS(view, *cpp2::assert_not_null(i))); } From aabaa8c179d70844530317710467821d28ace966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Pr=C3=B6tel?= Date: Sat, 24 Feb 2024 16:40:09 +0100 Subject: [PATCH 7/9] Expected files per compiler. --- .../test-results/apple-clang-14/pure2-new-basics.cpp.execution | 0 .../test-results/apple-clang-14/pure2-new-basics.cpp.output | 0 .../test-results/clang-12/pure2-new-basics.cpp.execution | 0 .../test-results/clang-12/pure2-new-basics.cpp.output | 0 .../test-results/clang-15/pure2-new-basics.cpp.execution | 0 .../test-results/clang-15/pure2-new-basics.cpp.output | 0 .../test-results/clang-18/pure2-new-basics.cpp.execution | 0 .../test-results/clang-18/pure2-new-basics.cpp.output | 0 .../test-results/gcc-13/pure2-new-basics.cpp.execution | 0 regression-tests/test-results/gcc-13/pure2-new-basics.cpp.output | 0 .../test-results/msvc-2022/pure2-new-basics.cpp.execution | 0 .../test-results/msvc-2022/pure2-new-basics.cpp.output | 0 12 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 regression-tests/test-results/apple-clang-14/pure2-new-basics.cpp.execution create mode 100644 regression-tests/test-results/apple-clang-14/pure2-new-basics.cpp.output create mode 100644 regression-tests/test-results/clang-12/pure2-new-basics.cpp.execution create mode 100644 regression-tests/test-results/clang-12/pure2-new-basics.cpp.output create mode 100644 regression-tests/test-results/clang-15/pure2-new-basics.cpp.execution create mode 100644 regression-tests/test-results/clang-15/pure2-new-basics.cpp.output create mode 100644 regression-tests/test-results/clang-18/pure2-new-basics.cpp.execution create mode 100644 regression-tests/test-results/clang-18/pure2-new-basics.cpp.output create mode 100644 regression-tests/test-results/gcc-13/pure2-new-basics.cpp.execution create mode 100644 regression-tests/test-results/gcc-13/pure2-new-basics.cpp.output create mode 100644 regression-tests/test-results/msvc-2022/pure2-new-basics.cpp.execution create mode 100644 regression-tests/test-results/msvc-2022/pure2-new-basics.cpp.output diff --git a/regression-tests/test-results/apple-clang-14/pure2-new-basics.cpp.execution b/regression-tests/test-results/apple-clang-14/pure2-new-basics.cpp.execution new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/apple-clang-14/pure2-new-basics.cpp.output b/regression-tests/test-results/apple-clang-14/pure2-new-basics.cpp.output new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/clang-12/pure2-new-basics.cpp.execution b/regression-tests/test-results/clang-12/pure2-new-basics.cpp.execution new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/clang-12/pure2-new-basics.cpp.output b/regression-tests/test-results/clang-12/pure2-new-basics.cpp.output new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/clang-15/pure2-new-basics.cpp.execution b/regression-tests/test-results/clang-15/pure2-new-basics.cpp.execution new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output b/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/clang-18/pure2-new-basics.cpp.execution b/regression-tests/test-results/clang-18/pure2-new-basics.cpp.execution new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/clang-18/pure2-new-basics.cpp.output b/regression-tests/test-results/clang-18/pure2-new-basics.cpp.output new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/gcc-13/pure2-new-basics.cpp.execution b/regression-tests/test-results/gcc-13/pure2-new-basics.cpp.execution new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/gcc-13/pure2-new-basics.cpp.output b/regression-tests/test-results/gcc-13/pure2-new-basics.cpp.output new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/msvc-2022/pure2-new-basics.cpp.execution b/regression-tests/test-results/msvc-2022/pure2-new-basics.cpp.execution new file mode 100644 index 000000000..e69de29bb diff --git a/regression-tests/test-results/msvc-2022/pure2-new-basics.cpp.output b/regression-tests/test-results/msvc-2022/pure2-new-basics.cpp.output new file mode 100644 index 000000000..e69de29bb From 1875bfcbd1225f6df2c5b6f7c2d0368f9169edab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Pr=C3=B6tel?= Date: Thu, 21 Mar 2024 22:32:53 +0100 Subject: [PATCH 8/9] Fix after merge. --- include/cpp2util.h | 8 +- .../pure2-intro-example-three-loops.cpp2 | 2 +- regression-tests/pure2-last-use.cpp2 | 162 +++++++++--------- regression-tests/pure2-new-basics.cpp2 | 15 +- 4 files changed, 96 insertions(+), 91 deletions(-) diff --git a/include/cpp2util.h b/include/cpp2util.h index 6dc77035e..7d7e5177b 100644 --- a/include/cpp2util.h +++ b/include/cpp2util.h @@ -713,12 +713,14 @@ struct { template class owning_reference { public: - explicit owning_reference(std::unique_ptr&& ptr):_ptr(assert_not_null(std::move(ptr))){} + explicit owning_reference(std::unique_ptr&& ptr):_ptr(cpp2::impl::assert_not_null(std::move(ptr))){} ~owning_reference() = default; + owning_reference(const owning_reference& ref) = delete; + owning_reference& operator=(const owning_reference& ref) noexcept = delete; owning_reference(owning_reference&& ref) = default; owning_reference& operator=(owning_reference&& ref) noexcept = default; - typename std::add_lvalue_reference::type operator*() const { return *assert_not_null(_ptr.get()); } - typename std::add_lvalue_reference::type operator->() const noexcept {return *assert_not_null(_ptr.get());} + typename std::add_lvalue_reference::type operator*() const { return *cpp2::impl::assert_not_null(_ptr.get()); } + typename std::add_lvalue_reference::type operator->() const noexcept {return *cpp2::impl::assert_not_null(_ptr.get());} auto get() const noexcept { return _ptr.get();} private: std::unique_ptr _ptr; diff --git a/regression-tests/pure2-intro-example-three-loops.cpp2 b/regression-tests/pure2-intro-example-three-loops.cpp2 index 6a7e95177..ecbbf4113 100644 --- a/regression-tests/pure2-intro-example-three-loops.cpp2 +++ b/regression-tests/pure2-intro-example-three-loops.cpp2 @@ -16,7 +16,7 @@ main: () -> int = { if (!p_i) { return 1; } - i := p_i*; + i := (move p_i*); while i* < view.ssize() next i*++ { print( view[i*] ); diff --git a/regression-tests/pure2-last-use.cpp2 b/regression-tests/pure2-last-use.cpp2 index 6a9c657f6..bc53696ce 100644 --- a/regression-tests/pure2-last-use.cpp2 +++ b/regression-tests/pure2-last-use.cpp2 @@ -8,57 +8,57 @@ identity_copy: (move x) -> _ requires !std::copyable = (move x); issue_313: () = { // _ = :() -> std::vector = { -// a := new(0); +// a := new(0)*; // return (a*, identity_copy(a)*); // }; // _ = :() -> std::vector = { -// a := new(0); +// a := new(0)*; // return (a&**, identity_copy(a)*); // }; _ = :() -> int = { - a := new(0); + a := new(0)*; return identity(a)* + identity(a)*; - b := new(0); + b := new(0)*; return identity(b)* = identity(b)*; - c := new(0); + c := new(0)*; return identity(c)* ^ identity(c)*; }; { - a := new(0); + a := new(0)*; identity(a)* = identity(a)*; - b := new(0); + b := new(0)*; _: int = identity(b)* = identity(b)*; - c := new(0); + c := new(0)*; if identity(c)* * identity(c)* { } - d := new(0); + d := new(0)*; if (identity(d)* - identity(d)*) { } - e := new(0); + e := new(0)*; _ = e is (e); - f := new(0); + f := new(0)*; _ = f is std::type_identity_t; // OK? - g := new(0); + g := new(0)*; for (identity(g)* + identity(g)*) do (_) { } - h := new(0); + h := new(0)*; while identity(h)* + identity(h)* { } - i := new(0); + i := new(0)*; do { } while identity(i)* + identity(i)*; - j := new(0); - k := new(0); + j := new(0)*; + k := new(0)*; _ = inspect identity(j)* + identity(j)* -> int { is (identity(k)* + identity(k)*) = 0; is _ = 0; @@ -66,7 +66,7 @@ issue_313: () = { } // { -// a := new(0); +// a := new(0)*; // _ = :() identity(a$)* + identity(a$)*; // } } @@ -114,7 +114,7 @@ issue_683: (args) = { issue_825: () = { _ = :(copy b: std::unique_ptr) f_copy(move b); _ = :(move c: std::unique_ptr) f_copy(move c); - _ = :(forward d) f_copy(d);(new(0)); + _ = :(forward d) f_copy(d);(new(0)*); } issue_832: () = { @@ -370,16 +370,16 @@ issue_857_9: @struct type = { } issue_869_0: @value type = { - operator=: (out this, move _: std::unique_ptr) = { } + operator=: (out this, move _: cpp2::owning_reference) = { } } issue_869_1: @union type = { i: issue_869_0; } -issue_869_2: () -> (res: issue_869_1 = ()) = { res.set_i(new(0)); } +issue_869_2: () -> (res: issue_869_1 = ()) = { res.set_i(new(0)*); } issue_884: () = { _ = :() = { - x := new(0); + x := new(0)*; if true { } { { f_inout(x); } @@ -388,7 +388,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_copy(move x); } @@ -399,7 +399,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_inout(x); } @@ -411,7 +411,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_copy(move x); if true { _ = 0; @@ -424,7 +424,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_copy(move x); @@ -437,7 +437,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { _ = 0; @@ -450,7 +450,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { _ = 0; @@ -463,7 +463,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { _ = 0; @@ -476,7 +476,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_copy(move x); @@ -489,7 +489,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_copy(move x); @@ -502,7 +502,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_inout(x); @@ -518,7 +518,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_inout(x); @@ -534,7 +534,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); if true { f_copy(move x); @@ -550,7 +550,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { if true { if true { @@ -563,7 +563,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { if true { if true { @@ -577,7 +577,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { } else { @@ -590,7 +590,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_copy(move x); } @@ -604,9 +604,9 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { - y := new(0); + y := new(0)*; f_copy(move x); f_copy(move y); } @@ -621,9 +621,9 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { - y := new(0); + y := new(0)*; if true { } else { f_copy(move x); @@ -633,7 +633,7 @@ issue_884: () = { else { if true { if true { - y := new(0); + y := new(0)*; f_copy(move y); f_inout(x); } @@ -643,9 +643,9 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { - y := new(0); + y := new(0)*; if true { } else { f_copy(move x); @@ -653,7 +653,7 @@ issue_884: () = { } } else { - y := new(0); + y := new(0)*; if true { if true { f_copy(move x); @@ -667,13 +667,13 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_copy(move x); } else { if true { - x := new(0); + x := new(0)*; if true { f_inout(x); } @@ -686,10 +686,10 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { if true { - x := new(0); + x := new(0)*; if true { f_inout(x); } @@ -705,7 +705,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_inout(x); @@ -719,7 +719,7 @@ issue_884: () = { }; _ = :() = { - x := new(0); + x := new(0)*; if true { if true { f_inout(x); @@ -782,9 +782,9 @@ issue_888_1: (copy _: std::string, copy size: move_only_function) = { } issue_890: () = { - x := new(0); + x := new(0)*; // assert(identity_copy(x)* == 0); - (x := new(0)) assert(identity(x)* == 0); + (x := new(0)*) assert(identity(x)* == 0); } issue_962: (s: ::std::string) = { @@ -804,13 +804,13 @@ enum_0: () = { underlying_type = ""; } enum_1: () = { - max_value := new(0); - min_value: std::reference_wrapper> = max_value; + max_value := new(0)*; + min_value: std::reference_wrapper> = max_value; // for (0) // do (copy x) // { - // v := new(identity_copy(x)); + // v := new(identity_copy(x))*; // if pred(v, min_value) { // min_value = std::ref(identity(v)); // Not using 'else' will never move 'v'. // } @@ -819,20 +819,20 @@ enum_1: () = { // } // } - y := new(false); + y := new(false)*; while identity(y)* { - v := new(0); + v := new(0)*; f_copy(move v); } - z := new(false); + z := new(false)*; do { - v := new(0); + v := new(0)*; f_copy(move v); } while identity(z)*; } enum_2: () = { - umax := new(0); + umax := new(0)*; if pred(umax) { } else if pred(umax) { @@ -874,14 +874,14 @@ deferred_non_copyable_2: () -> (p: std::unique_ptr) = { loops: () = { _ = :() = { - x := new(0); + x := new(0)*; for (0) do (_) f_inout(x); }; _ = :() = { - x := new(0); + x := new(0)*; for (0) next f_inout(x) do (_) @@ -889,14 +889,14 @@ loops: () = { }; _ = :() = { - x := new(0); + x := new(0)*; for (0) do (_) assert(x.get()); }; _ = :() = { - x := new(0); + x := new(0)*; if true { f_copy(move x); } @@ -913,10 +913,10 @@ captures: namespace = { // Skip non captured name in function expression f: () = { - x := new(0); + x := new(0)*; f_copy(move x); id := :(x) -> forward _ = x; - y := new(0); + y := new(0)*; assert(id(y)& == y&); } @@ -939,13 +939,13 @@ t: @struct type = { g: () = { _ = :() = { - x := new(0); + x := new(0)*; f_copy(move x); _ = :() std::array()$; // Fails on Clang 12 (lambda in unevaluated context). }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); // _ = :() -> int = (:() x$*)$(); }; @@ -955,7 +955,7 @@ g: () = { loops_and_captures: () = { _ = :() = { - x := new(0); + x := new(0)*; f_copy(move x); for (:(x) x) do (_) @@ -963,7 +963,7 @@ loops_and_captures: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_copy(move x); for (:() -> _ = { using captures::x; @@ -974,7 +974,7 @@ loops_and_captures: () = { }; // _ = :() = { -// x := new(0); +// x := new(0)*; // for (:() x$*) // do (_) // { } @@ -993,17 +993,17 @@ types: @struct type = { skip_hidden_names: () = { _ = :() = { - x := new(0); + x := new(0)*; f_copy(move x); - (copy x := new(0)) + (copy x := new(0)*) f_copy(move x); }; // _ = :() = { -// x := new(0); +// x := new(0)*; // _ = :() = { // _ = x$; -// x := new(1); +// x := new(1)*; // _ = :() = { // _ = x$; // }; @@ -1011,17 +1011,17 @@ skip_hidden_names: () = { // }; _ = :() = { - // x := new(0); + // x := new(0)*; // f_copy(x); // for (0) // do (copy x) // _ = identity_copy(x); - (copy x := new(0)) + (copy x := new(0)*) f_copy(move x); }; _ = :() = { - x := new(0); + x := new(0)*; f_inout(x); { f_copy(move x); @@ -1031,10 +1031,10 @@ skip_hidden_names: () = { }; _ = :() = { - x := new(0); + x := new(0)*; f_copy(move x); _ = :() = { - static_assert(std::is_same_v>); + static_assert(std::is_same_v>); using captures::x; f_inout(x); }; diff --git a/regression-tests/pure2-new-basics.cpp2 b/regression-tests/pure2-new-basics.cpp2 index fb19ae6b9..1be5078c4 100644 --- a/regression-tests/pure2-new-basics.cpp2 +++ b/regression-tests/pure2-new-basics.cpp2 @@ -19,23 +19,26 @@ test_movable : () = { a.test(); call_test(a); - b : Movable = a; + b : Movable = (move a); b.test(); call_test(b); //a.test(); // not allowed } +move_to : (move c : _) = { + call_test(c*); + c*.test(); +} + test_movable_ref : () = { a : _ = new(); if (a) { a**.test(); call_test(a**); - //b : _ = a**; // cannot create copy - c : _ = a*; - call_test(c*); - c*.test(); + //b : _ = a**; // cannot create copy + move_to(move a*); // a**.test(); // not allowed } } @@ -75,7 +78,7 @@ test_copyable_ref : () = { b.test(); a**.test(); // allowed - c : _ = a*; // move owning reference from optional + c : _ = (move a*); // move owning reference from optional call_test(c*); c*.test(); //a**.test(); // no longer allowed From 47bb31f44f9b6c9dfc1e6df13e0edf9b68584b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Pr=C3=B6tel?= Date: Fri, 22 Mar 2024 05:53:41 +0100 Subject: [PATCH 9/9] Upddate test output. --- regression-tests/clang++-15.patch | 2505 +++++++++++++++++ regression-tests/run-tests.sh | 0 .../pure2-assert-expected-not-null.cpp.output | 4 +- .../pure2-interpolation.cpp.execution | 2 +- .../clang-15/pure2-new-basics.cpp.output | 135 + .../test-results/mixed-type-safety-1.cpp | 2 +- .../pure2-intro-example-three-loops.cpp | 5 +- .../test-results/pure2-last-use.cpp | 170 +- .../test-results/pure2-new-basics.cpp2.output | 3 +- 9 files changed, 2734 insertions(+), 92 deletions(-) create mode 100644 regression-tests/clang++-15.patch mode change 100644 => 100755 regression-tests/run-tests.sh diff --git a/regression-tests/clang++-15.patch b/regression-tests/clang++-15.patch new file mode 100644 index 000000000..3bfa201b6 --- /dev/null +++ b/regression-tests/clang++-15.patch @@ -0,0 +1,2505 @@ + +diff --git a/regression-tests/test-results/mixed-type-safety-1.cpp b/regression-tests/test-results/mixed-type-safety-1.cpp +index f175980..20aecdc 100644 +--- a/regression-tests/test-results/mixed-type-safety-1.cpp ++++ b/regression-tests/test-results/mixed-type-safety-1.cpp +@@ -58,7 +58,7 @@ auto print(cpp2::impl::in msg, cpp2::impl::in b) -> void + print( "1 is int? ", cpp2::impl::is(1)); + + auto c {cpp2_new()}; // safe by construction +- Shape* s {CPP2_UFCS(get)(cpp2::move(c))}; // safe by Lifetime ++ Shape* s {CPP2_UFCS(get)((*cpp2::impl::assert_not_null(cpp2::move(c))))}; // safe by Lifetime + print(" +s* is Shape? ", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); + print( "s* is Circle? ", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); + print( "s* is Square? ", cpp2::impl::is(*cpp2::impl::assert_not_null(cpp2::move(s)))); + + +diff --git a/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output b/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output +index 17021ed..cfefcc2 100644 +--- a/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output ++++ b/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output +@@ -5,7 +5,7 @@ pure2-assert-expected-not-null.cpp2:7:10: error: no member named 'expected' in n + std::expected ex {4}; + ~~~~~^~~~~~~~ + unexpected +-/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/exception:107:8: note: 'unexpected' declared here ++/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/exception:95:8: note: 'unexpected' declared here + void unexpected() __attribute__ ((__noreturn__)); + ^ + pure2-assert-expected-not-null.cpp2:9:193: error: use of undeclared identifier 'ex' +@@ -18,7 +18,7 @@ pure2-assert-expected-not-null.cpp2:14:10: error: no member named 'expected' in + std::expected ex {std::unexpected(false)}; + ~~~~~^~~~~~~~ + unexpected +-/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/exception:107:8: note: 'unexpected' declared here ++/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/exception:95:8: note: 'unexpected' declared here + void unexpected() __attribute__ ((__noreturn__)); + ^ + pure2-assert-expected-not-null.cpp2:15:52: error: use of undeclared identifier 'ex' + + +diff --git a/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution b/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution +index 850cfc6..7dbfcb5 100644 +--- a/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution ++++ b/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution +@@ -9,4 +9,4 @@ g0g0g + pl(ug$h + 0pl(ug$h + Dog kennel color mauve price 3.14 in stock = true +-Dog kennel color mauve price 3.14 in stock = true ++Dog kennel color mauve price 3.140000 in stock = true + + +diff --git a/regression-tests/test-results/pure2-intro-example-three-loops.cpp b/regression-tests/test-results/pure2-intro-example-three-loops.cpp +index 500f293..ea0af88 100644 +--- a/regression-tests/test-results/pure2-intro-example-three-loops.cpp ++++ b/regression-tests/test-results/pure2-intro-example-three-loops.cpp +@@ -45,7 +45,12 @@ auto decorate_and_print(auto& thing) -> void{ + "hello", "big", "world"}; + std::span view {words}; + +- auto i {cpp2_new(0)}; ++ auto p_i {cpp2_new(0)}; ++ if ((!(p_i))) { ++ return 1; ++ } ++ auto i {*cpp2::impl::assert_not_null(cpp2::move(p_i))}; ++ + for( ; cpp2::impl::cmp_less(*cpp2::impl::assert_not_null(i),CPP2_UFCS(ssize)(view)); ++*cpp2::impl::assert_not_null(i) ) { + print(CPP2_ASSERT_IN_BOUNDS(view, *cpp2::impl::assert_not_null(i))); + } + + +diff --git a/regression-tests/test-results/clang-15/pure2-intro-example-three-loops.cpp.output b/regression-tests/test-results/clang-15/pure2-intro-example-three-loops.cpp.output +index e69de29..b3b3fdb 100644 +--- a/regression-tests/test-results/clang-15/pure2-intro-example-three-loops.cpp.output ++++ b/regression-tests/test-results/clang-15/pure2-intro-example-three-loops.cpp.output +@@ -0,0 +1,7 @@ ++pure2-intro-example-three-loops.cpp2:19:10: error: call to implicitly-deleted copy constructor of 'cpp2::owning_reference' ++ auto i {*cpp2::impl::assert_not_null(cpp2::move(p_i))}; ++ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++../../../include/cpp2util.h:718:5: note: copy constructor is implicitly deleted because 'owning_reference' has a user-declared move constructor ++ owning_reference(owning_reference&& ref) = default; ++ ^ ++1 error generated. + + +diff --git a/regression-tests/test-results/pure2-last-use.cpp b/regression-tests/test-results/pure2-last-use.cpp +index 8d72435..ec663a6 100644 +--- a/regression-tests/test-results/pure2-last-use.cpp ++++ b/regression-tests/test-results/pure2-last-use.cpp +@@ -362,9 +362,9 @@ class issue_857_9: public issue_857_8 { + }; + + class issue_869_0 { +- public: explicit issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2); ++ public: explicit issue_869_0([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2); + #line 373 "pure2-last-use.cpp2" +- public: auto operator=([[maybe_unused]] std::unique_ptr&& unnamed_param_2) -> issue_869_0& ; ++ public: auto operator=([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2) -> issue_869_0& ; + public: [[nodiscard]] auto operator<=>([[maybe_unused]] issue_869_0 const& that) const& -> std::strong_ordering = default; + public: issue_869_0([[maybe_unused]] issue_869_0 const& that); + +@@ -520,57 +520,57 @@ requires (!(std::copyable)) { return std::move(cpp2::move(x)); } + #line 9 "pure2-last-use.cpp2" + auto issue_313() -> void{ + // _ = :() -> std::vector = { +-// a := new(0); ++// a := new(0)*; + // return (a*, identity_copy(a)*); + // }; + // _ = :() -> std::vector = { +-// a := new(0); ++// a := new(0)*; + // return (a&**, identity_copy(a)*); + // }; + static_cast([]() mutable -> int{ +- auto a {cpp2_new(0)}; ++ auto a {*cpp2::impl::assert_not_null(cpp2_new(0))}; + return *cpp2::impl::assert_not_null(identity(a)) + *cpp2::impl::assert_not_null(identity(a)); + +- auto b {cpp2_new(0)}; ++ auto b {*cpp2::impl::assert_not_null(cpp2_new(0))}; + return *cpp2::impl::assert_not_null(identity(b)) = *cpp2::impl::assert_not_null(identity(b)); + +- auto c {cpp2_new(0)}; ++ auto c {*cpp2::impl::assert_not_null(cpp2_new(0))}; + return *cpp2::impl::assert_not_null(identity(c)) ^ *cpp2::impl::assert_not_null(identity(c)); + }); + { +- auto a {cpp2_new(0)}; ++ auto a {*cpp2::impl::assert_not_null(cpp2_new(0))}; + *cpp2::impl::assert_not_null(identity(a)) = *cpp2::impl::assert_not_null(identity(a)); + +- auto b {cpp2_new(0)}; ++ auto b {*cpp2::impl::assert_not_null(cpp2_new(0))}; + int auto_1 {*cpp2::impl::assert_not_null(identity(b)) = *cpp2::impl::assert_not_null(identity(b))}; + +- auto c {cpp2_new(0)}; ++ auto c {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (*cpp2::impl::assert_not_null(identity(c)) * *cpp2::impl::assert_not_null(identity(c))) {} + +- auto d {cpp2_new(0)}; ++ auto d {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if ((*cpp2::impl::assert_not_null(identity(d)) - *cpp2::impl::assert_not_null(identity(d)))) {} + +- auto e {cpp2_new(0)}; ++ auto e {*cpp2::impl::assert_not_null(cpp2_new(0))}; + static_cast(cpp2::impl::is(e, (e))); + +- auto f {cpp2_new(0)}; ++ auto f {*cpp2::impl::assert_not_null(cpp2_new(0))}; + static_cast(cpp2::impl::is>(f));// OK? + +- auto g {cpp2_new(0)}; ++ auto g {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { *cpp2::impl::assert_not_null(identity(g)) + *cpp2::impl::assert_not_null(identity(g)) } ) + {} + +- auto h {cpp2_new(0)}; ++ auto h {*cpp2::impl::assert_not_null(cpp2_new(0))}; + while( *cpp2::impl::assert_not_null(identity(h)) + *cpp2::impl::assert_not_null(identity(h)) ) + {} + +- auto i {cpp2_new(0)}; ++ auto i {*cpp2::impl::assert_not_null(cpp2_new(0))}; + do {} while ( + *cpp2::impl::assert_not_null(identity(i)) + *cpp2::impl::assert_not_null(identity(i))); + +- auto j {cpp2_new(0)}; +- auto k {cpp2_new(0)}; ++ auto j {*cpp2::impl::assert_not_null(cpp2_new(0))}; ++ auto k {*cpp2::impl::assert_not_null(cpp2_new(0))}; + static_cast([&] () -> int { auto&& _expr = *cpp2::impl::assert_not_null(identity(j)) + *cpp2::impl::assert_not_null(identity(j)); + if (cpp2::impl::is(_expr, (*cpp2::impl::assert_not_null(identity(k)) + *cpp2::impl::assert_not_null(identity(k))))) { if constexpr( requires{0;} ) if constexpr( std::is_convertible_v ) return 0; else return int{}; else return int{}; } + else return 0; } +@@ -578,7 +578,7 @@ auto issue_313() -> void{ + + } + // { +-// a := new(0); ++// a := new(0)*; + // _ = :() identity(a$)* + identity(a$)*; + // } + } +@@ -613,7 +613,7 @@ auto issue_683(auto const& args) -> void{ + auto issue_825() -> void{ + static_cast([](std::unique_ptr b) mutable -> auto { return f_copy(std::move(cpp2::move(b))); }); + static_cast([](std::unique_ptr&& c) mutable -> auto { return f_copy(std::move(cpp2::move(c))); }); +- static_cast([](auto&& d) mutable -> auto { return f_copy(CPP2_FORWARD(d)); }(cpp2_new(0))); ++ static_cast([](auto&& d) mutable -> auto { return f_copy(CPP2_FORWARD(d)); }(*cpp2::impl::assert_not_null(cpp2_new(0)))); + } + + #line 120 "pure2-last-use.cpp2" +@@ -730,10 +730,10 @@ int gi {0}; + auto issue_857_9::g2() && -> void { f_inout(cpp2::move((*this)).c); } + + #line 373 "pure2-last-use.cpp2" +- issue_869_0::issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2){} ++ issue_869_0::issue_869_0([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2){} + #line 373 "pure2-last-use.cpp2" +- auto issue_869_0::operator=([[maybe_unused]] std::unique_ptr&& unnamed_param_2) -> issue_869_0& { +- return *this; } ++ auto issue_869_0::operator=([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2) -> issue_869_0& { ++ return *this; } + + + issue_869_0::issue_869_0([[maybe_unused]] issue_869_0 const& that){} +@@ -781,13 +781,13 @@ issue_869_1::issue_869_1(issue_869_1 const& that) + } + #line 378 "pure2-last-use.cpp2" + [[nodiscard]] auto issue_869_2() -> issue_869_2_ret{ +- issue_869_1 res {}; CPP2_UFCS(set_i)(res, cpp2_new(0)); ++ issue_869_1 res {}; CPP2_UFCS(set_i)(res, *cpp2::impl::assert_not_null(cpp2_new(0))); + #line 379 "pure2-last-use.cpp2" + return res; } + #line 380 "pure2-last-use.cpp2" + auto issue_884() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) {} + { + {f_inout(x); } +@@ -796,7 +796,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } +@@ -807,7 +807,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_inout(x); + } +@@ -819,7 +819,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + if (true) { + static_cast(0); +@@ -832,7 +832,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -845,7 +845,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + static_cast(0); +@@ -858,7 +858,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + static_cast(0); +@@ -871,7 +871,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + static_cast(0); +@@ -884,7 +884,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -897,7 +897,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -910,7 +910,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_inout(x); +@@ -926,7 +926,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_inout(x); +@@ -942,7 +942,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -958,7 +958,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + if (true) { +@@ -971,7 +971,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + if (true) { +@@ -985,7 +985,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + } + else { +@@ -998,7 +998,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } +@@ -1012,9 +1012,9 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + f_copy(std::move(cpp2::move(y))); + } +@@ -1029,9 +1029,9 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) {} + else { + f_copy(std::move(cpp2::move(x))); +@@ -1041,7 +1041,7 @@ auto issue_884() -> void{ + else { + if (true) { + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(y))); + f_inout(x); + } +@@ -1051,9 +1051,9 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) {} + else { + f_copy(std::move(cpp2::move(x))); +@@ -1061,7 +1061,7 @@ auto issue_884() -> void{ + } + } + else { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -1075,13 +1075,13 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } + else { + if (true) { +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_inout(x); + } +@@ -1094,10 +1094,10 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_inout(x); + } +@@ -1113,7 +1113,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + + if (true) { + f_inout(x); +@@ -1127,7 +1127,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + f_inout(x); +@@ -1193,9 +1193,9 @@ auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, move_only_functio + + #line 784 "pure2-last-use.cpp2" + auto issue_890() -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + { +-auto const& x{cpp2_new(0)}; ++auto const& x{*cpp2::impl::assert_not_null(cpp2_new(0))}; + // assert(identity_copy(x)* == 0); + #line 787 "pure2-last-use.cpp2" + if (cpp2::cpp2_default.is_active() && !(*cpp2::impl::assert_not_null(identity(x)) == 0) ) { cpp2::cpp2_default.report_violation(""); } +@@ -1224,13 +1224,13 @@ auto enum_0() -> void{ + } + #line 806 "pure2-last-use.cpp2" + auto enum_1() -> void{ +- auto max_value {cpp2_new(0)}; +- std::reference_wrapper const> min_value {cpp2::move(max_value)}; ++ auto max_value {*cpp2::impl::assert_not_null(cpp2_new(0))}; ++ std::reference_wrapper const> min_value {cpp2::move(max_value)}; + + // for (0) + // do (copy x) + // { +- // v := new(identity_copy(x)); ++ // v := new(identity_copy(x))*; + // if pred(v, min_value) { + // min_value = std::ref(identity(v)); // Not using 'else' will never move 'v'. + // } +@@ -1239,21 +1239,21 @@ auto enum_1() -> void{ + // } + // } + +- auto y {cpp2_new(false)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(false))}; + while( *cpp2::impl::assert_not_null(identity(y)) ) { +- auto v {cpp2_new(0)}; ++ auto v {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(v))); + } + +- auto z {cpp2_new(false)}; ++ auto z {*cpp2::impl::assert_not_null(cpp2_new(false))}; + do { +- auto v {cpp2_new(0)}; ++ auto v {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(v))); + } while ( *cpp2::impl::assert_not_null(identity(z))); + } + #line 834 "pure2-last-use.cpp2" + auto enum_2() -> void{ +- auto umax {cpp2_new(0)}; ++ auto umax {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (pred(umax)) { + } + else {if (pred(umax)) { +@@ -1299,14 +1299,14 @@ return std::move(p.value()); } + #line 875 "pure2-last-use.cpp2" + auto loops() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) + f_inout(x); + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + + [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) { do +@@ -1314,14 +1314,14 @@ auto loops() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) + if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(get)(x)) ) { cpp2::cpp2_default.report_violation(""); } + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } +@@ -1337,10 +1337,10 @@ namespace captures { + + #line 915 "pure2-last-use.cpp2" + auto f() -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + auto id {[](auto const& x) mutable -> auto&& { return x; }}; +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (cpp2::cpp2_default.is_active() && !(&cpp2::move(id)(y) == &y) ) { cpp2::cpp2_default.report_violation(""); } + } + +@@ -1360,13 +1360,13 @@ auto f() -> void{ + #line 940 "pure2-last-use.cpp2" + auto g() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + static_cast([_0 = std::array auto { return identity(x); }(0)>()]() mutable -> auto { return _0; });// Fails on Clang 12 (lambda in unevaluated context). + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(cpp2::move(x)); + // _ = :() -> int = (:() x$*)$(); + }); +@@ -1377,7 +1377,7 @@ auto g() -> void{ + #line 956 "pure2-last-use.cpp2" + auto loops_and_captures() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { [](auto const& x) mutable -> auto { return x; } } ) +@@ -1385,7 +1385,7 @@ auto loops_and_captures() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + for ( + +@@ -1395,7 +1395,7 @@ auto loops_and_captures() -> void{ + }); + + // _ = :() = { +-// x := new(0); ++// x := new(0)*; + // for (:() x$*) + // do (_) + // { } +@@ -1405,10 +1405,10 @@ auto loops_and_captures() -> void{ + #line 994 "pure2-last-use.cpp2" + auto skip_hidden_names() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + { +-auto x{cpp2_new(0)}; ++auto x{*cpp2::impl::assert_not_null(cpp2_new(0))}; + + #line 999 "pure2-last-use.cpp2" + f_copy(std::move(cpp2::move(x))); +@@ -1417,10 +1417,10 @@ auto x{cpp2_new(0)}; + }); + + // _ = :() = { +-// x := new(0); ++// x := new(0)*; + // _ = :() = { + // _ = x$; +-// x := new(1); ++// x := new(1)*; + // _ = :() = { + // _ = x$; + // }; +@@ -1429,8 +1429,8 @@ auto x{cpp2_new(0)}; + + static_cast([]() mutable -> void{ + { +-auto x{cpp2_new(0)}; +- // x := new(0); ++auto x{*cpp2::impl::assert_not_null(cpp2_new(0))}; ++ // x := new(0)*; + // f_copy(x); + // for (0) + // do (copy x) +@@ -1443,7 +1443,7 @@ auto x{cpp2_new(0)}; + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + { + f_copy(std::move(cpp2::move(x))); +@@ -1453,10 +1453,10 @@ auto x{cpp2_new(0)}; + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + static_cast([]() mutable -> void{ +- static_assert(std::is_same_v>); ++ static_assert(std::is_same_v>); + using captures::x; + f_inout(x); + }); + + +diff --git a/regression-tests/test-results/pure2-new-basics.cpp2.output b/regression-tests/test-results/pure2-new-basics.cpp2.output +index 1be2648..cb7037c 100644 +--- a/regression-tests/test-results/pure2-new-basics.cpp2.output ++++ b/regression-tests/test-results/pure2-new-basics.cpp2.output +@@ -1,2 +1,3 @@ +-pure2-new-basics.cpp2... ok (all Cpp2, passes safety checks) ++pure2-new-basics.cpp2... ++pure2-new-basics.cpp2(40,9): error: invalid statement encountered inside a compound-statement (at 'move_test') + + + +diff --git a/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output b/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output +index e69de29..4b68b87 100644 +--- a/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output ++++ b/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output +@@ -0,0 +1,135 @@ ++pure2-new-basics.cpp2:33:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:33:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:34:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:34:43: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:36:18: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ auto c {*cpp2::assert_not_null(std::move(a))}; ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:37:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(c)); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:38:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(std::move(c)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:46:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:46:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:51:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(std::move(a))))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:51:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(std::move(a))))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:71:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:71:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:72:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:72:43: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:73:18: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ auto b {*cpp2::assert_not_null(*cpp2::assert_not_null(a))}; // create copy ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:73:41: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ auto b {*cpp2::assert_not_null(*cpp2::assert_not_null(a))}; // create copy ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:76:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a))));// allowed ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:76:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a))));// allowed ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++fatal error: too many errors emitted, stopping now [-ferror-limit=] ++20 errors generated. + + +diff --git a/regression-tests/test-results/mixed-type-safety-1.cpp b/regression-tests/test-results/mixed-type-safety-1.cpp +index f175980..20aecdc 100644 +--- a/regression-tests/test-results/mixed-type-safety-1.cpp ++++ b/regression-tests/test-results/mixed-type-safety-1.cpp +@@ -58,7 +58,7 @@ auto print(cpp2::impl::in msg, cpp2::impl::in b) -> void + print( "1 is int? ", cpp2::impl::is(1)); + + auto c {cpp2_new()}; // safe by construction +- Shape* s {CPP2_UFCS(get)(cpp2::move(c))}; // safe by Lifetime ++ Shape* s {CPP2_UFCS(get)((*cpp2::impl::assert_not_null(cpp2::move(c))))}; // safe by Lifetime + print(" +s* is Shape? ", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); + print( "s* is Circle? ", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); + print( "s* is Square? ", cpp2::impl::is(*cpp2::impl::assert_not_null(cpp2::move(s)))); + + +diff --git a/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output b/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output +index 17021ed..cfefcc2 100644 +--- a/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output ++++ b/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output +@@ -5,7 +5,7 @@ pure2-assert-expected-not-null.cpp2:7:10: error: no member named 'expected' in n + std::expected ex {4}; + ~~~~~^~~~~~~~ + unexpected +-/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/exception:107:8: note: 'unexpected' declared here ++/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/exception:95:8: note: 'unexpected' declared here + void unexpected() __attribute__ ((__noreturn__)); + ^ + pure2-assert-expected-not-null.cpp2:9:193: error: use of undeclared identifier 'ex' +@@ -18,7 +18,7 @@ pure2-assert-expected-not-null.cpp2:14:10: error: no member named 'expected' in + std::expected ex {std::unexpected(false)}; + ~~~~~^~~~~~~~ + unexpected +-/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/exception:107:8: note: 'unexpected' declared here ++/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/exception:95:8: note: 'unexpected' declared here + void unexpected() __attribute__ ((__noreturn__)); + ^ + pure2-assert-expected-not-null.cpp2:15:52: error: use of undeclared identifier 'ex' + + +diff --git a/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution b/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution +index 850cfc6..7dbfcb5 100644 +--- a/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution ++++ b/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution +@@ -9,4 +9,4 @@ g0g0g + pl(ug$h + 0pl(ug$h + Dog kennel color mauve price 3.14 in stock = true +-Dog kennel color mauve price 3.14 in stock = true ++Dog kennel color mauve price 3.140000 in stock = true + + +diff --git a/regression-tests/test-results/pure2-intro-example-three-loops.cpp b/regression-tests/test-results/pure2-intro-example-three-loops.cpp +index 500f293..ea0af88 100644 +--- a/regression-tests/test-results/pure2-intro-example-three-loops.cpp ++++ b/regression-tests/test-results/pure2-intro-example-three-loops.cpp +@@ -45,7 +45,12 @@ auto decorate_and_print(auto& thing) -> void{ + "hello", "big", "world"}; + std::span view {words}; + +- auto i {cpp2_new(0)}; ++ auto p_i {cpp2_new(0)}; ++ if ((!(p_i))) { ++ return 1; ++ } ++ auto i {*cpp2::impl::assert_not_null(cpp2::move(p_i))}; ++ + for( ; cpp2::impl::cmp_less(*cpp2::impl::assert_not_null(i),CPP2_UFCS(ssize)(view)); ++*cpp2::impl::assert_not_null(i) ) { + print(CPP2_ASSERT_IN_BOUNDS(view, *cpp2::impl::assert_not_null(i))); + } + + +diff --git a/regression-tests/test-results/pure2-last-use.cpp b/regression-tests/test-results/pure2-last-use.cpp +index 8d72435..ec663a6 100644 +--- a/regression-tests/test-results/pure2-last-use.cpp ++++ b/regression-tests/test-results/pure2-last-use.cpp +@@ -362,9 +362,9 @@ class issue_857_9: public issue_857_8 { + }; + + class issue_869_0 { +- public: explicit issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2); ++ public: explicit issue_869_0([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2); + #line 373 "pure2-last-use.cpp2" +- public: auto operator=([[maybe_unused]] std::unique_ptr&& unnamed_param_2) -> issue_869_0& ; ++ public: auto operator=([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2) -> issue_869_0& ; + public: [[nodiscard]] auto operator<=>([[maybe_unused]] issue_869_0 const& that) const& -> std::strong_ordering = default; + public: issue_869_0([[maybe_unused]] issue_869_0 const& that); + +@@ -520,57 +520,57 @@ requires (!(std::copyable)) { return std::move(cpp2::move(x)); } + #line 9 "pure2-last-use.cpp2" + auto issue_313() -> void{ + // _ = :() -> std::vector = { +-// a := new(0); ++// a := new(0)*; + // return (a*, identity_copy(a)*); + // }; + // _ = :() -> std::vector = { +-// a := new(0); ++// a := new(0)*; + // return (a&**, identity_copy(a)*); + // }; + static_cast([]() mutable -> int{ +- auto a {cpp2_new(0)}; ++ auto a {*cpp2::impl::assert_not_null(cpp2_new(0))}; + return *cpp2::impl::assert_not_null(identity(a)) + *cpp2::impl::assert_not_null(identity(a)); + +- auto b {cpp2_new(0)}; ++ auto b {*cpp2::impl::assert_not_null(cpp2_new(0))}; + return *cpp2::impl::assert_not_null(identity(b)) = *cpp2::impl::assert_not_null(identity(b)); + +- auto c {cpp2_new(0)}; ++ auto c {*cpp2::impl::assert_not_null(cpp2_new(0))}; + return *cpp2::impl::assert_not_null(identity(c)) ^ *cpp2::impl::assert_not_null(identity(c)); + }); + { +- auto a {cpp2_new(0)}; ++ auto a {*cpp2::impl::assert_not_null(cpp2_new(0))}; + *cpp2::impl::assert_not_null(identity(a)) = *cpp2::impl::assert_not_null(identity(a)); + +- auto b {cpp2_new(0)}; ++ auto b {*cpp2::impl::assert_not_null(cpp2_new(0))}; + int auto_1 {*cpp2::impl::assert_not_null(identity(b)) = *cpp2::impl::assert_not_null(identity(b))}; + +- auto c {cpp2_new(0)}; ++ auto c {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (*cpp2::impl::assert_not_null(identity(c)) * *cpp2::impl::assert_not_null(identity(c))) {} + +- auto d {cpp2_new(0)}; ++ auto d {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if ((*cpp2::impl::assert_not_null(identity(d)) - *cpp2::impl::assert_not_null(identity(d)))) {} + +- auto e {cpp2_new(0)}; ++ auto e {*cpp2::impl::assert_not_null(cpp2_new(0))}; + static_cast(cpp2::impl::is(e, (e))); + +- auto f {cpp2_new(0)}; ++ auto f {*cpp2::impl::assert_not_null(cpp2_new(0))}; + static_cast(cpp2::impl::is>(f));// OK? + +- auto g {cpp2_new(0)}; ++ auto g {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { *cpp2::impl::assert_not_null(identity(g)) + *cpp2::impl::assert_not_null(identity(g)) } ) + {} + +- auto h {cpp2_new(0)}; ++ auto h {*cpp2::impl::assert_not_null(cpp2_new(0))}; + while( *cpp2::impl::assert_not_null(identity(h)) + *cpp2::impl::assert_not_null(identity(h)) ) + {} + +- auto i {cpp2_new(0)}; ++ auto i {*cpp2::impl::assert_not_null(cpp2_new(0))}; + do {} while ( + *cpp2::impl::assert_not_null(identity(i)) + *cpp2::impl::assert_not_null(identity(i))); + +- auto j {cpp2_new(0)}; +- auto k {cpp2_new(0)}; ++ auto j {*cpp2::impl::assert_not_null(cpp2_new(0))}; ++ auto k {*cpp2::impl::assert_not_null(cpp2_new(0))}; + static_cast([&] () -> int { auto&& _expr = *cpp2::impl::assert_not_null(identity(j)) + *cpp2::impl::assert_not_null(identity(j)); + if (cpp2::impl::is(_expr, (*cpp2::impl::assert_not_null(identity(k)) + *cpp2::impl::assert_not_null(identity(k))))) { if constexpr( requires{0;} ) if constexpr( std::is_convertible_v ) return 0; else return int{}; else return int{}; } + else return 0; } +@@ -578,7 +578,7 @@ auto issue_313() -> void{ + + } + // { +-// a := new(0); ++// a := new(0)*; + // _ = :() identity(a$)* + identity(a$)*; + // } + } +@@ -613,7 +613,7 @@ auto issue_683(auto const& args) -> void{ + auto issue_825() -> void{ + static_cast([](std::unique_ptr b) mutable -> auto { return f_copy(std::move(cpp2::move(b))); }); + static_cast([](std::unique_ptr&& c) mutable -> auto { return f_copy(std::move(cpp2::move(c))); }); +- static_cast([](auto&& d) mutable -> auto { return f_copy(CPP2_FORWARD(d)); }(cpp2_new(0))); ++ static_cast([](auto&& d) mutable -> auto { return f_copy(CPP2_FORWARD(d)); }(*cpp2::impl::assert_not_null(cpp2_new(0)))); + } + + #line 120 "pure2-last-use.cpp2" +@@ -730,10 +730,10 @@ int gi {0}; + auto issue_857_9::g2() && -> void { f_inout(cpp2::move((*this)).c); } + + #line 373 "pure2-last-use.cpp2" +- issue_869_0::issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2){} ++ issue_869_0::issue_869_0([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2){} + #line 373 "pure2-last-use.cpp2" +- auto issue_869_0::operator=([[maybe_unused]] std::unique_ptr&& unnamed_param_2) -> issue_869_0& { +- return *this; } ++ auto issue_869_0::operator=([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2) -> issue_869_0& { ++ return *this; } + + + issue_869_0::issue_869_0([[maybe_unused]] issue_869_0 const& that){} +@@ -781,13 +781,13 @@ issue_869_1::issue_869_1(issue_869_1 const& that) + } + #line 378 "pure2-last-use.cpp2" + [[nodiscard]] auto issue_869_2() -> issue_869_2_ret{ +- issue_869_1 res {}; CPP2_UFCS(set_i)(res, cpp2_new(0)); ++ issue_869_1 res {}; CPP2_UFCS(set_i)(res, *cpp2::impl::assert_not_null(cpp2_new(0))); + #line 379 "pure2-last-use.cpp2" + return res; } + #line 380 "pure2-last-use.cpp2" + auto issue_884() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) {} + { + {f_inout(x); } +@@ -796,7 +796,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } +@@ -807,7 +807,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_inout(x); + } +@@ -819,7 +819,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + if (true) { + static_cast(0); +@@ -832,7 +832,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -845,7 +845,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + static_cast(0); +@@ -858,7 +858,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + static_cast(0); +@@ -871,7 +871,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + static_cast(0); +@@ -884,7 +884,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -897,7 +897,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -910,7 +910,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_inout(x); +@@ -926,7 +926,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_inout(x); +@@ -942,7 +942,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -958,7 +958,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + if (true) { +@@ -971,7 +971,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + if (true) { +@@ -985,7 +985,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + } + else { +@@ -998,7 +998,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } +@@ -1012,9 +1012,9 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + f_copy(std::move(cpp2::move(y))); + } +@@ -1029,9 +1029,9 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) {} + else { + f_copy(std::move(cpp2::move(x))); +@@ -1041,7 +1041,7 @@ auto issue_884() -> void{ + else { + if (true) { + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(y))); + f_inout(x); + } +@@ -1051,9 +1051,9 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) {} + else { + f_copy(std::move(cpp2::move(x))); +@@ -1061,7 +1061,7 @@ auto issue_884() -> void{ + } + } + else { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -1075,13 +1075,13 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } + else { + if (true) { +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_inout(x); + } +@@ -1094,10 +1094,10 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_inout(x); + } +@@ -1113,7 +1113,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + + if (true) { + f_inout(x); +@@ -1127,7 +1127,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + f_inout(x); +@@ -1193,9 +1193,9 @@ auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, move_only_functio + + #line 784 "pure2-last-use.cpp2" + auto issue_890() -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + { +-auto const& x{cpp2_new(0)}; ++auto const& x{*cpp2::impl::assert_not_null(cpp2_new(0))}; + // assert(identity_copy(x)* == 0); + #line 787 "pure2-last-use.cpp2" + if (cpp2::cpp2_default.is_active() && !(*cpp2::impl::assert_not_null(identity(x)) == 0) ) { cpp2::cpp2_default.report_violation(""); } +@@ -1224,13 +1224,13 @@ auto enum_0() -> void{ + } + #line 806 "pure2-last-use.cpp2" + auto enum_1() -> void{ +- auto max_value {cpp2_new(0)}; +- std::reference_wrapper const> min_value {cpp2::move(max_value)}; ++ auto max_value {*cpp2::impl::assert_not_null(cpp2_new(0))}; ++ std::reference_wrapper const> min_value {cpp2::move(max_value)}; + + // for (0) + // do (copy x) + // { +- // v := new(identity_copy(x)); ++ // v := new(identity_copy(x))*; + // if pred(v, min_value) { + // min_value = std::ref(identity(v)); // Not using 'else' will never move 'v'. + // } +@@ -1239,21 +1239,21 @@ auto enum_1() -> void{ + // } + // } + +- auto y {cpp2_new(false)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(false))}; + while( *cpp2::impl::assert_not_null(identity(y)) ) { +- auto v {cpp2_new(0)}; ++ auto v {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(v))); + } + +- auto z {cpp2_new(false)}; ++ auto z {*cpp2::impl::assert_not_null(cpp2_new(false))}; + do { +- auto v {cpp2_new(0)}; ++ auto v {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(v))); + } while ( *cpp2::impl::assert_not_null(identity(z))); + } + #line 834 "pure2-last-use.cpp2" + auto enum_2() -> void{ +- auto umax {cpp2_new(0)}; ++ auto umax {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (pred(umax)) { + } + else {if (pred(umax)) { +@@ -1299,14 +1299,14 @@ return std::move(p.value()); } + #line 875 "pure2-last-use.cpp2" + auto loops() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) + f_inout(x); + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + + [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) { do +@@ -1314,14 +1314,14 @@ auto loops() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) + if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(get)(x)) ) { cpp2::cpp2_default.report_violation(""); } + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } +@@ -1337,10 +1337,10 @@ namespace captures { + + #line 915 "pure2-last-use.cpp2" + auto f() -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + auto id {[](auto const& x) mutable -> auto&& { return x; }}; +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (cpp2::cpp2_default.is_active() && !(&cpp2::move(id)(y) == &y) ) { cpp2::cpp2_default.report_violation(""); } + } + +@@ -1360,13 +1360,13 @@ auto f() -> void{ + #line 940 "pure2-last-use.cpp2" + auto g() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + static_cast([_0 = std::array auto { return identity(x); }(0)>()]() mutable -> auto { return _0; });// Fails on Clang 12 (lambda in unevaluated context). + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(cpp2::move(x)); + // _ = :() -> int = (:() x$*)$(); + }); +@@ -1377,7 +1377,7 @@ auto g() -> void{ + #line 956 "pure2-last-use.cpp2" + auto loops_and_captures() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { [](auto const& x) mutable -> auto { return x; } } ) +@@ -1385,7 +1385,7 @@ auto loops_and_captures() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + for ( + +@@ -1395,7 +1395,7 @@ auto loops_and_captures() -> void{ + }); + + // _ = :() = { +-// x := new(0); ++// x := new(0)*; + // for (:() x$*) + // do (_) + // { } +@@ -1405,10 +1405,10 @@ auto loops_and_captures() -> void{ + #line 994 "pure2-last-use.cpp2" + auto skip_hidden_names() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + { +-auto x{cpp2_new(0)}; ++auto x{*cpp2::impl::assert_not_null(cpp2_new(0))}; + + #line 999 "pure2-last-use.cpp2" + f_copy(std::move(cpp2::move(x))); +@@ -1417,10 +1417,10 @@ auto x{cpp2_new(0)}; + }); + + // _ = :() = { +-// x := new(0); ++// x := new(0)*; + // _ = :() = { + // _ = x$; +-// x := new(1); ++// x := new(1)*; + // _ = :() = { + // _ = x$; + // }; +@@ -1429,8 +1429,8 @@ auto x{cpp2_new(0)}; + + static_cast([]() mutable -> void{ + { +-auto x{cpp2_new(0)}; +- // x := new(0); ++auto x{*cpp2::impl::assert_not_null(cpp2_new(0))}; ++ // x := new(0)*; + // f_copy(x); + // for (0) + // do (copy x) +@@ -1443,7 +1443,7 @@ auto x{cpp2_new(0)}; + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + { + f_copy(std::move(cpp2::move(x))); +@@ -1453,10 +1453,10 @@ auto x{cpp2_new(0)}; + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + static_cast([]() mutable -> void{ +- static_assert(std::is_same_v>); ++ static_assert(std::is_same_v>); + using captures::x; + f_inout(x); + }); + + +diff --git a/regression-tests/test-results/clang-15/pure2-last-use.cpp.output b/regression-tests/test-results/clang-15/pure2-last-use.cpp.output +index e69de29..14dd077 100644 +--- a/regression-tests/test-results/clang-15/pure2-last-use.cpp.output ++++ b/regression-tests/test-results/clang-15/pure2-last-use.cpp.output +@@ -0,0 +1,34 @@ ++pure2-last-use.cpp2:142:5: error: no matching function for call to 'f_inout' ++ f_inout(cpp2::move(x)); ++ ^~~~~~~ ++pure2-last-use.cpp2:1:6: note: candidate function [with unnamed_param_1:auto = std::unique_ptr] not viable: expects an lvalue for 1st argument ++auto f_inout([[maybe_unused]] auto& unnamed_param_1) -> void{} ++ ^ ++pure2-last-use.cpp2:175:5: error: no matching function for call to 'f_inout' ++ f_inout(cpp2::move((*this)).b); ++ ^~~~~~~ ++pure2-last-use.cpp2:1:6: note: candidate function [with unnamed_param_1:auto = std::unique_ptr] not viable: expects an lvalue for 1st argument ++auto f_inout([[maybe_unused]] auto& unnamed_param_1) -> void{} ++ ^ ++pure2-last-use.cpp2:366:39: error: no matching function for call to 'f_inout' ++ auto issue_857_9::g0() && -> void { f_inout(cpp2::move((*this)).a); } ++ ^~~~~~~ ++pure2-last-use.cpp2:1:6: note: candidate function [with unnamed_param_1:auto = std::unique_ptr] not viable: expects an lvalue for 1st argument ++auto f_inout([[maybe_unused]] auto& unnamed_param_1) -> void{} ++ ^ ++pure2-last-use.cpp2:808:63: error: no matching constructor for initialization of 'std::reference_wrapper>' ++ std::reference_wrapper const> min_value {cpp2::move(max_value)}; ++ ^ ~~~~~~~~~~~~~~~~~~~~~~~ ++/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/refwrap.h:326:7: note: candidate constructor not viable: no known conversion from 'cpp2::owning_reference' to 'const std::reference_wrapper>' for 1st argument ++ reference_wrapper(const reference_wrapper&) = default; ++ ^ ++/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/refwrap.h:321:2: note: candidate template ignored: substitution failure [with _Up = cpp2::owning_reference, $1 = void, $2 = void]: call to deleted function '_S_fun' ++ reference_wrapper(_Up&& __uref) ++ ^ ++pure2-last-use.cpp2:949:5: error: no matching function for call to 'f_inout' ++ f_inout(cpp2::move(x)); ++ ^~~~~~~ ++pure2-last-use.cpp2:1:6: note: candidate function [with unnamed_param_1:auto = cpp2::owning_reference] not viable: expects an lvalue for 1st argument ++auto f_inout([[maybe_unused]] auto& unnamed_param_1) -> void{} ++ ^ ++5 errors generated. + + +diff --git a/regression-tests/test-results/pure2-new-basics.cpp2.output b/regression-tests/test-results/pure2-new-basics.cpp2.output +index 1be2648..cb7037c 100644 +--- a/regression-tests/test-results/pure2-new-basics.cpp2.output ++++ b/regression-tests/test-results/pure2-new-basics.cpp2.output +@@ -1,2 +1,3 @@ +-pure2-new-basics.cpp2... ok (all Cpp2, passes safety checks) ++pure2-new-basics.cpp2... ++pure2-new-basics.cpp2(40,9): error: invalid statement encountered inside a compound-statement (at 'move_test') + + + +diff --git a/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output b/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output +index e69de29..4b68b87 100644 +--- a/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output ++++ b/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output +@@ -0,0 +1,135 @@ ++pure2-new-basics.cpp2:33:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:33:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:34:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:34:43: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:36:18: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ auto c {*cpp2::assert_not_null(std::move(a))}; ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:37:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(c)); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:38:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(std::move(c)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:46:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:46:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:51:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(std::move(a))))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:51:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(std::move(a))))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:71:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:71:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:72:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:72:43: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:73:18: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ auto b {*cpp2::assert_not_null(*cpp2::assert_not_null(a))}; // create copy ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:73:41: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ auto b {*cpp2::assert_not_null(*cpp2::assert_not_null(a))}; // create copy ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:76:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a))));// allowed ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:76:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a))));// allowed ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++fatal error: too many errors emitted, stopping now [-ferror-limit=] ++20 errors generated. + + +diff --git a/regression-tests/test-results/mixed-type-safety-1.cpp b/regression-tests/test-results/mixed-type-safety-1.cpp +index f175980..20aecdc 100644 +--- a/regression-tests/test-results/mixed-type-safety-1.cpp ++++ b/regression-tests/test-results/mixed-type-safety-1.cpp +@@ -58,7 +58,7 @@ auto print(cpp2::impl::in msg, cpp2::impl::in b) -> void + print( "1 is int? ", cpp2::impl::is(1)); + + auto c {cpp2_new()}; // safe by construction +- Shape* s {CPP2_UFCS(get)(cpp2::move(c))}; // safe by Lifetime ++ Shape* s {CPP2_UFCS(get)((*cpp2::impl::assert_not_null(cpp2::move(c))))}; // safe by Lifetime + print(" +s* is Shape? ", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); + print( "s* is Circle? ", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); + print( "s* is Square? ", cpp2::impl::is(*cpp2::impl::assert_not_null(cpp2::move(s)))); + + +diff --git a/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output b/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output +index 17021ed..cfefcc2 100644 +--- a/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output ++++ b/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output +@@ -5,7 +5,7 @@ pure2-assert-expected-not-null.cpp2:7:10: error: no member named 'expected' in n + std::expected ex {4}; + ~~~~~^~~~~~~~ + unexpected +-/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/exception:107:8: note: 'unexpected' declared here ++/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/exception:95:8: note: 'unexpected' declared here + void unexpected() __attribute__ ((__noreturn__)); + ^ + pure2-assert-expected-not-null.cpp2:9:193: error: use of undeclared identifier 'ex' +@@ -18,7 +18,7 @@ pure2-assert-expected-not-null.cpp2:14:10: error: no member named 'expected' in + std::expected ex {std::unexpected(false)}; + ~~~~~^~~~~~~~ + unexpected +-/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/exception:107:8: note: 'unexpected' declared here ++/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/exception:95:8: note: 'unexpected' declared here + void unexpected() __attribute__ ((__noreturn__)); + ^ + pure2-assert-expected-not-null.cpp2:15:52: error: use of undeclared identifier 'ex' + + +diff --git a/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution b/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution +index 850cfc6..7dbfcb5 100644 +--- a/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution ++++ b/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution +@@ -9,4 +9,4 @@ g0g0g + pl(ug$h + 0pl(ug$h + Dog kennel color mauve price 3.14 in stock = true +-Dog kennel color mauve price 3.14 in stock = true ++Dog kennel color mauve price 3.140000 in stock = true + + +diff --git a/regression-tests/test-results/pure2-intro-example-three-loops.cpp b/regression-tests/test-results/pure2-intro-example-three-loops.cpp +index 500f293..c204473 100644 +--- a/regression-tests/test-results/pure2-intro-example-three-loops.cpp ++++ b/regression-tests/test-results/pure2-intro-example-three-loops.cpp +@@ -21,7 +21,7 @@ auto decorate_and_print(auto& thing) -> void; + + #line 10 "pure2-intro-example-three-loops.cpp2" + [[nodiscard]] auto main() -> int; +-#line 35 "pure2-intro-example-three-loops.cpp2" ++#line 31 "pure2-intro-example-three-loops.cpp2" + + #line 1 "pure2-intro-example-three-loops.cpp2" + +@@ -45,7 +45,8 @@ auto decorate_and_print(auto& thing) -> void{ + "hello", "big", "world"}; + std::span view {words}; + +- auto i {cpp2_new(0)}; ++ auto i {*cpp2::impl::assert_not_null(cpp2_new(0))}; ++ + for( ; cpp2::impl::cmp_less(*cpp2::impl::assert_not_null(i),CPP2_UFCS(ssize)(view)); ++*cpp2::impl::assert_not_null(i) ) { + print(CPP2_ASSERT_IN_BOUNDS(view, *cpp2::impl::assert_not_null(i))); + } + + +diff --git a/regression-tests/test-results/pure2-last-use.cpp b/regression-tests/test-results/pure2-last-use.cpp +index 8d72435..ec663a6 100644 +--- a/regression-tests/test-results/pure2-last-use.cpp ++++ b/regression-tests/test-results/pure2-last-use.cpp +@@ -362,9 +362,9 @@ class issue_857_9: public issue_857_8 { + }; + + class issue_869_0 { +- public: explicit issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2); ++ public: explicit issue_869_0([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2); + #line 373 "pure2-last-use.cpp2" +- public: auto operator=([[maybe_unused]] std::unique_ptr&& unnamed_param_2) -> issue_869_0& ; ++ public: auto operator=([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2) -> issue_869_0& ; + public: [[nodiscard]] auto operator<=>([[maybe_unused]] issue_869_0 const& that) const& -> std::strong_ordering = default; + public: issue_869_0([[maybe_unused]] issue_869_0 const& that); + +@@ -520,57 +520,57 @@ requires (!(std::copyable)) { return std::move(cpp2::move(x)); } + #line 9 "pure2-last-use.cpp2" + auto issue_313() -> void{ + // _ = :() -> std::vector = { +-// a := new(0); ++// a := new(0)*; + // return (a*, identity_copy(a)*); + // }; + // _ = :() -> std::vector = { +-// a := new(0); ++// a := new(0)*; + // return (a&**, identity_copy(a)*); + // }; + static_cast([]() mutable -> int{ +- auto a {cpp2_new(0)}; ++ auto a {*cpp2::impl::assert_not_null(cpp2_new(0))}; + return *cpp2::impl::assert_not_null(identity(a)) + *cpp2::impl::assert_not_null(identity(a)); + +- auto b {cpp2_new(0)}; ++ auto b {*cpp2::impl::assert_not_null(cpp2_new(0))}; + return *cpp2::impl::assert_not_null(identity(b)) = *cpp2::impl::assert_not_null(identity(b)); + +- auto c {cpp2_new(0)}; ++ auto c {*cpp2::impl::assert_not_null(cpp2_new(0))}; + return *cpp2::impl::assert_not_null(identity(c)) ^ *cpp2::impl::assert_not_null(identity(c)); + }); + { +- auto a {cpp2_new(0)}; ++ auto a {*cpp2::impl::assert_not_null(cpp2_new(0))}; + *cpp2::impl::assert_not_null(identity(a)) = *cpp2::impl::assert_not_null(identity(a)); + +- auto b {cpp2_new(0)}; ++ auto b {*cpp2::impl::assert_not_null(cpp2_new(0))}; + int auto_1 {*cpp2::impl::assert_not_null(identity(b)) = *cpp2::impl::assert_not_null(identity(b))}; + +- auto c {cpp2_new(0)}; ++ auto c {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (*cpp2::impl::assert_not_null(identity(c)) * *cpp2::impl::assert_not_null(identity(c))) {} + +- auto d {cpp2_new(0)}; ++ auto d {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if ((*cpp2::impl::assert_not_null(identity(d)) - *cpp2::impl::assert_not_null(identity(d)))) {} + +- auto e {cpp2_new(0)}; ++ auto e {*cpp2::impl::assert_not_null(cpp2_new(0))}; + static_cast(cpp2::impl::is(e, (e))); + +- auto f {cpp2_new(0)}; ++ auto f {*cpp2::impl::assert_not_null(cpp2_new(0))}; + static_cast(cpp2::impl::is>(f));// OK? + +- auto g {cpp2_new(0)}; ++ auto g {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { *cpp2::impl::assert_not_null(identity(g)) + *cpp2::impl::assert_not_null(identity(g)) } ) + {} + +- auto h {cpp2_new(0)}; ++ auto h {*cpp2::impl::assert_not_null(cpp2_new(0))}; + while( *cpp2::impl::assert_not_null(identity(h)) + *cpp2::impl::assert_not_null(identity(h)) ) + {} + +- auto i {cpp2_new(0)}; ++ auto i {*cpp2::impl::assert_not_null(cpp2_new(0))}; + do {} while ( + *cpp2::impl::assert_not_null(identity(i)) + *cpp2::impl::assert_not_null(identity(i))); + +- auto j {cpp2_new(0)}; +- auto k {cpp2_new(0)}; ++ auto j {*cpp2::impl::assert_not_null(cpp2_new(0))}; ++ auto k {*cpp2::impl::assert_not_null(cpp2_new(0))}; + static_cast([&] () -> int { auto&& _expr = *cpp2::impl::assert_not_null(identity(j)) + *cpp2::impl::assert_not_null(identity(j)); + if (cpp2::impl::is(_expr, (*cpp2::impl::assert_not_null(identity(k)) + *cpp2::impl::assert_not_null(identity(k))))) { if constexpr( requires{0;} ) if constexpr( std::is_convertible_v ) return 0; else return int{}; else return int{}; } + else return 0; } +@@ -578,7 +578,7 @@ auto issue_313() -> void{ + + } + // { +-// a := new(0); ++// a := new(0)*; + // _ = :() identity(a$)* + identity(a$)*; + // } + } +@@ -613,7 +613,7 @@ auto issue_683(auto const& args) -> void{ + auto issue_825() -> void{ + static_cast([](std::unique_ptr b) mutable -> auto { return f_copy(std::move(cpp2::move(b))); }); + static_cast([](std::unique_ptr&& c) mutable -> auto { return f_copy(std::move(cpp2::move(c))); }); +- static_cast([](auto&& d) mutable -> auto { return f_copy(CPP2_FORWARD(d)); }(cpp2_new(0))); ++ static_cast([](auto&& d) mutable -> auto { return f_copy(CPP2_FORWARD(d)); }(*cpp2::impl::assert_not_null(cpp2_new(0)))); + } + + #line 120 "pure2-last-use.cpp2" +@@ -730,10 +730,10 @@ int gi {0}; + auto issue_857_9::g2() && -> void { f_inout(cpp2::move((*this)).c); } + + #line 373 "pure2-last-use.cpp2" +- issue_869_0::issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2){} ++ issue_869_0::issue_869_0([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2){} + #line 373 "pure2-last-use.cpp2" +- auto issue_869_0::operator=([[maybe_unused]] std::unique_ptr&& unnamed_param_2) -> issue_869_0& { +- return *this; } ++ auto issue_869_0::operator=([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2) -> issue_869_0& { ++ return *this; } + + + issue_869_0::issue_869_0([[maybe_unused]] issue_869_0 const& that){} +@@ -781,13 +781,13 @@ issue_869_1::issue_869_1(issue_869_1 const& that) + } + #line 378 "pure2-last-use.cpp2" + [[nodiscard]] auto issue_869_2() -> issue_869_2_ret{ +- issue_869_1 res {}; CPP2_UFCS(set_i)(res, cpp2_new(0)); ++ issue_869_1 res {}; CPP2_UFCS(set_i)(res, *cpp2::impl::assert_not_null(cpp2_new(0))); + #line 379 "pure2-last-use.cpp2" + return res; } + #line 380 "pure2-last-use.cpp2" + auto issue_884() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) {} + { + {f_inout(x); } +@@ -796,7 +796,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } +@@ -807,7 +807,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_inout(x); + } +@@ -819,7 +819,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + if (true) { + static_cast(0); +@@ -832,7 +832,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -845,7 +845,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + static_cast(0); +@@ -858,7 +858,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + static_cast(0); +@@ -871,7 +871,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + static_cast(0); +@@ -884,7 +884,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -897,7 +897,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -910,7 +910,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_inout(x); +@@ -926,7 +926,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_inout(x); +@@ -942,7 +942,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -958,7 +958,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + if (true) { +@@ -971,7 +971,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + if (true) { +@@ -985,7 +985,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + } + else { +@@ -998,7 +998,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } +@@ -1012,9 +1012,9 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + f_copy(std::move(cpp2::move(y))); + } +@@ -1029,9 +1029,9 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) {} + else { + f_copy(std::move(cpp2::move(x))); +@@ -1041,7 +1041,7 @@ auto issue_884() -> void{ + else { + if (true) { + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(y))); + f_inout(x); + } +@@ -1051,9 +1051,9 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) {} + else { + f_copy(std::move(cpp2::move(x))); +@@ -1061,7 +1061,7 @@ auto issue_884() -> void{ + } + } + else { +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + f_copy(std::move(cpp2::move(x))); +@@ -1075,13 +1075,13 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } + else { + if (true) { +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_inout(x); + } +@@ -1094,10 +1094,10 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_inout(x); + } +@@ -1113,7 +1113,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + + if (true) { + f_inout(x); +@@ -1127,7 +1127,7 @@ auto issue_884() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + if (true) { + f_inout(x); +@@ -1193,9 +1193,9 @@ auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, move_only_functio + + #line 784 "pure2-last-use.cpp2" + auto issue_890() -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + { +-auto const& x{cpp2_new(0)}; ++auto const& x{*cpp2::impl::assert_not_null(cpp2_new(0))}; + // assert(identity_copy(x)* == 0); + #line 787 "pure2-last-use.cpp2" + if (cpp2::cpp2_default.is_active() && !(*cpp2::impl::assert_not_null(identity(x)) == 0) ) { cpp2::cpp2_default.report_violation(""); } +@@ -1224,13 +1224,13 @@ auto enum_0() -> void{ + } + #line 806 "pure2-last-use.cpp2" + auto enum_1() -> void{ +- auto max_value {cpp2_new(0)}; +- std::reference_wrapper const> min_value {cpp2::move(max_value)}; ++ auto max_value {*cpp2::impl::assert_not_null(cpp2_new(0))}; ++ std::reference_wrapper const> min_value {cpp2::move(max_value)}; + + // for (0) + // do (copy x) + // { +- // v := new(identity_copy(x)); ++ // v := new(identity_copy(x))*; + // if pred(v, min_value) { + // min_value = std::ref(identity(v)); // Not using 'else' will never move 'v'. + // } +@@ -1239,21 +1239,21 @@ auto enum_1() -> void{ + // } + // } + +- auto y {cpp2_new(false)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(false))}; + while( *cpp2::impl::assert_not_null(identity(y)) ) { +- auto v {cpp2_new(0)}; ++ auto v {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(v))); + } + +- auto z {cpp2_new(false)}; ++ auto z {*cpp2::impl::assert_not_null(cpp2_new(false))}; + do { +- auto v {cpp2_new(0)}; ++ auto v {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(v))); + } while ( *cpp2::impl::assert_not_null(identity(z))); + } + #line 834 "pure2-last-use.cpp2" + auto enum_2() -> void{ +- auto umax {cpp2_new(0)}; ++ auto umax {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (pred(umax)) { + } + else {if (pred(umax)) { +@@ -1299,14 +1299,14 @@ return std::move(p.value()); } + #line 875 "pure2-last-use.cpp2" + auto loops() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) + f_inout(x); + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + + [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) { do +@@ -1314,14 +1314,14 @@ auto loops() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) + if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(get)(x)) ) { cpp2::cpp2_default.report_violation(""); } + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (true) { + f_copy(std::move(cpp2::move(x))); + } +@@ -1337,10 +1337,10 @@ namespace captures { + + #line 915 "pure2-last-use.cpp2" + auto f() -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + auto id {[](auto const& x) mutable -> auto&& { return x; }}; +- auto y {cpp2_new(0)}; ++ auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; + if (cpp2::cpp2_default.is_active() && !(&cpp2::move(id)(y) == &y) ) { cpp2::cpp2_default.report_violation(""); } + } + +@@ -1360,13 +1360,13 @@ auto f() -> void{ + #line 940 "pure2-last-use.cpp2" + auto g() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + static_cast([_0 = std::array auto { return identity(x); }(0)>()]() mutable -> auto { return _0; });// Fails on Clang 12 (lambda in unevaluated context). + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(cpp2::move(x)); + // _ = :() -> int = (:() x$*)$(); + }); +@@ -1377,7 +1377,7 @@ auto g() -> void{ + #line 956 "pure2-last-use.cpp2" + auto loops_and_captures() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + for ( + [[maybe_unused]] auto const& unnamed_param_1 : { [](auto const& x) mutable -> auto { return x; } } ) +@@ -1385,7 +1385,7 @@ auto loops_and_captures() -> void{ + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + for ( + +@@ -1395,7 +1395,7 @@ auto loops_and_captures() -> void{ + }); + + // _ = :() = { +-// x := new(0); ++// x := new(0)*; + // for (:() x$*) + // do (_) + // { } +@@ -1405,10 +1405,10 @@ auto loops_and_captures() -> void{ + #line 994 "pure2-last-use.cpp2" + auto skip_hidden_names() -> void{ + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + { +-auto x{cpp2_new(0)}; ++auto x{*cpp2::impl::assert_not_null(cpp2_new(0))}; + + #line 999 "pure2-last-use.cpp2" + f_copy(std::move(cpp2::move(x))); +@@ -1417,10 +1417,10 @@ auto x{cpp2_new(0)}; + }); + + // _ = :() = { +-// x := new(0); ++// x := new(0)*; + // _ = :() = { + // _ = x$; +-// x := new(1); ++// x := new(1)*; + // _ = :() = { + // _ = x$; + // }; +@@ -1429,8 +1429,8 @@ auto x{cpp2_new(0)}; + + static_cast([]() mutable -> void{ + { +-auto x{cpp2_new(0)}; +- // x := new(0); ++auto x{*cpp2::impl::assert_not_null(cpp2_new(0))}; ++ // x := new(0)*; + // f_copy(x); + // for (0) + // do (copy x) +@@ -1443,7 +1443,7 @@ auto x{cpp2_new(0)}; + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_inout(x); + { + f_copy(std::move(cpp2::move(x))); +@@ -1453,10 +1453,10 @@ auto x{cpp2_new(0)}; + }); + + static_cast([]() mutable -> void{ +- auto x {cpp2_new(0)}; ++ auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; + f_copy(std::move(cpp2::move(x))); + static_cast([]() mutable -> void{ +- static_assert(std::is_same_v>); ++ static_assert(std::is_same_v>); + using captures::x; + f_inout(x); + }); + + +diff --git a/regression-tests/test-results/pure2-new-basics.cpp2.output b/regression-tests/test-results/pure2-new-basics.cpp2.output +index 1be2648..cb7037c 100644 +--- a/regression-tests/test-results/pure2-new-basics.cpp2.output ++++ b/regression-tests/test-results/pure2-new-basics.cpp2.output +@@ -1,2 +1,3 @@ +-pure2-new-basics.cpp2... ok (all Cpp2, passes safety checks) ++pure2-new-basics.cpp2... ++pure2-new-basics.cpp2(40,9): error: invalid statement encountered inside a compound-statement (at 'move_test') + + + +diff --git a/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output b/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output +index e69de29..4b68b87 100644 +--- a/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output ++++ b/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output +@@ -0,0 +1,135 @@ ++pure2-new-basics.cpp2:33:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:33:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:34:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:34:43: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:36:18: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ auto c {*cpp2::assert_not_null(std::move(a))}; ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:37:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(c)); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:38:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(std::move(c)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:46:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:46:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:51:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(std::move(a))))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:51:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(std::move(a))))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:71:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:71:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:72:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:72:43: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:73:18: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ auto b {*cpp2::assert_not_null(*cpp2::assert_not_null(a))}; // create copy ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:73:41: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ auto b {*cpp2::assert_not_null(*cpp2::assert_not_null(a))}; // create copy ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:76:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a))));// allowed ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++pure2-new-basics.cpp2:76:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? ++ CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a))));// allowed ++ ^~~~~~~~~~~~~~~~~~~~~ ++ cpp2::impl::assert_not_null ++../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here ++auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) ++ ^ ++fatal error: too many errors emitted, stopping now [-ferror-limit=] ++20 errors generated. + diff --git a/regression-tests/run-tests.sh b/regression-tests/run-tests.sh old mode 100644 new mode 100755 diff --git a/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output b/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output index 17021ed74..cfefcc2d4 100644 --- a/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output +++ b/regression-tests/test-results/clang-15/pure2-assert-expected-not-null.cpp.output @@ -5,7 +5,7 @@ pure2-assert-expected-not-null.cpp2:7:10: error: no member named 'expected' in n std::expected ex {4}; ~~~~~^~~~~~~~ unexpected -/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/exception:107:8: note: 'unexpected' declared here +/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/exception:95:8: note: 'unexpected' declared here void unexpected() __attribute__ ((__noreturn__)); ^ pure2-assert-expected-not-null.cpp2:9:193: error: use of undeclared identifier 'ex' @@ -18,7 +18,7 @@ pure2-assert-expected-not-null.cpp2:14:10: error: no member named 'expected' in std::expected ex {std::unexpected(false)}; ~~~~~^~~~~~~~ unexpected -/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/exception:107:8: note: 'unexpected' declared here +/usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/exception:95:8: note: 'unexpected' declared here void unexpected() __attribute__ ((__noreturn__)); ^ pure2-assert-expected-not-null.cpp2:15:52: error: use of undeclared identifier 'ex' diff --git a/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution b/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution index 850cfc6bf..7dbfcb544 100644 --- a/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution +++ b/regression-tests/test-results/clang-15/pure2-interpolation.cpp.execution @@ -9,4 +9,4 @@ g0g0g pl(ug$h 0pl(ug$h Dog kennel color mauve price 3.14 in stock = true -Dog kennel color mauve price 3.14 in stock = true +Dog kennel color mauve price 3.140000 in stock = true diff --git a/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output b/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output index e69de29bb..4b68b8797 100644 --- a/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output +++ b/regression-tests/test-results/clang-15/pure2-new-basics.cpp.output @@ -0,0 +1,135 @@ +pure2-new-basics.cpp2:33:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:33:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:34:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:34:43: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:36:18: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + auto c {*cpp2::assert_not_null(std::move(a))}; + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:37:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + call_test(*cpp2::assert_not_null(c)); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:38:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + CPP2_UFCS(test)((*cpp2::assert_not_null(std::move(c)))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:46:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:46:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:51:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(std::move(a))))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:51:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(std::move(a))))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:71:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:71:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a)))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:72:20: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:72:43: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + call_test(*cpp2::assert_not_null(*cpp2::assert_not_null(a))); + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:73:18: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + auto b {*cpp2::assert_not_null(*cpp2::assert_not_null(a))}; // create copy + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:73:41: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + auto b {*cpp2::assert_not_null(*cpp2::assert_not_null(a))}; // create copy + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:76:27: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a))));// allowed + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +pure2-new-basics.cpp2:76:50: error: no member named 'assert_not_null' in namespace 'cpp2'; did you mean 'cpp2::impl::assert_not_null'? + CPP2_UFCS(test)((*cpp2::assert_not_null(*cpp2::assert_not_null(a))));// allowed + ^~~~~~~~~~~~~~~~~~~~~ + cpp2::impl::assert_not_null +../../../include/cpp2util.h:513:6: note: 'cpp2::impl::assert_not_null' declared here +auto assert_not_null(auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto) + ^ +fatal error: too many errors emitted, stopping now [-ferror-limit=] +20 errors generated. diff --git a/regression-tests/test-results/mixed-type-safety-1.cpp b/regression-tests/test-results/mixed-type-safety-1.cpp index f175980cb..20aecdc22 100644 --- a/regression-tests/test-results/mixed-type-safety-1.cpp +++ b/regression-tests/test-results/mixed-type-safety-1.cpp @@ -58,7 +58,7 @@ auto print(cpp2::impl::in msg, cpp2::impl::in b) -> void print( "1 is int? ", cpp2::impl::is(1)); auto c {cpp2_new()}; // safe by construction - Shape* s {CPP2_UFCS(get)(cpp2::move(c))}; // safe by Lifetime + Shape* s {CPP2_UFCS(get)((*cpp2::impl::assert_not_null(cpp2::move(c))))}; // safe by Lifetime print("\ns* is Shape? ", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); print( "s* is Circle? ", cpp2::impl::is(*cpp2::impl::assert_not_null(s))); print( "s* is Square? ", cpp2::impl::is(*cpp2::impl::assert_not_null(cpp2::move(s)))); diff --git a/regression-tests/test-results/pure2-intro-example-three-loops.cpp b/regression-tests/test-results/pure2-intro-example-three-loops.cpp index 500f293ed..c20447340 100644 --- a/regression-tests/test-results/pure2-intro-example-three-loops.cpp +++ b/regression-tests/test-results/pure2-intro-example-three-loops.cpp @@ -21,7 +21,7 @@ auto decorate_and_print(auto& thing) -> void; #line 10 "pure2-intro-example-three-loops.cpp2" [[nodiscard]] auto main() -> int; -#line 35 "pure2-intro-example-three-loops.cpp2" +#line 31 "pure2-intro-example-three-loops.cpp2" #line 1 "pure2-intro-example-three-loops.cpp2" @@ -45,7 +45,8 @@ auto decorate_and_print(auto& thing) -> void{ "hello", "big", "world"}; std::span view {words}; - auto i {cpp2_new(0)}; + auto i {*cpp2::impl::assert_not_null(cpp2_new(0))}; + for( ; cpp2::impl::cmp_less(*cpp2::impl::assert_not_null(i),CPP2_UFCS(ssize)(view)); ++*cpp2::impl::assert_not_null(i) ) { print(CPP2_ASSERT_IN_BOUNDS(view, *cpp2::impl::assert_not_null(i))); } diff --git a/regression-tests/test-results/pure2-last-use.cpp b/regression-tests/test-results/pure2-last-use.cpp index 8d72435df..ec663a6ea 100644 --- a/regression-tests/test-results/pure2-last-use.cpp +++ b/regression-tests/test-results/pure2-last-use.cpp @@ -362,9 +362,9 @@ class issue_857_9: public issue_857_8 { }; class issue_869_0 { - public: explicit issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2); + public: explicit issue_869_0([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2); #line 373 "pure2-last-use.cpp2" - public: auto operator=([[maybe_unused]] std::unique_ptr&& unnamed_param_2) -> issue_869_0& ; + public: auto operator=([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2) -> issue_869_0& ; public: [[nodiscard]] auto operator<=>([[maybe_unused]] issue_869_0 const& that) const& -> std::strong_ordering = default; public: issue_869_0([[maybe_unused]] issue_869_0 const& that); @@ -520,57 +520,57 @@ requires (!(std::copyable)) { return std::move(cpp2::move(x)); } #line 9 "pure2-last-use.cpp2" auto issue_313() -> void{ // _ = :() -> std::vector = { -// a := new(0); +// a := new(0)*; // return (a*, identity_copy(a)*); // }; // _ = :() -> std::vector = { -// a := new(0); +// a := new(0)*; // return (a&**, identity_copy(a)*); // }; static_cast([]() mutable -> int{ - auto a {cpp2_new(0)}; + auto a {*cpp2::impl::assert_not_null(cpp2_new(0))}; return *cpp2::impl::assert_not_null(identity(a)) + *cpp2::impl::assert_not_null(identity(a)); - auto b {cpp2_new(0)}; + auto b {*cpp2::impl::assert_not_null(cpp2_new(0))}; return *cpp2::impl::assert_not_null(identity(b)) = *cpp2::impl::assert_not_null(identity(b)); - auto c {cpp2_new(0)}; + auto c {*cpp2::impl::assert_not_null(cpp2_new(0))}; return *cpp2::impl::assert_not_null(identity(c)) ^ *cpp2::impl::assert_not_null(identity(c)); }); { - auto a {cpp2_new(0)}; + auto a {*cpp2::impl::assert_not_null(cpp2_new(0))}; *cpp2::impl::assert_not_null(identity(a)) = *cpp2::impl::assert_not_null(identity(a)); - auto b {cpp2_new(0)}; + auto b {*cpp2::impl::assert_not_null(cpp2_new(0))}; int auto_1 {*cpp2::impl::assert_not_null(identity(b)) = *cpp2::impl::assert_not_null(identity(b))}; - auto c {cpp2_new(0)}; + auto c {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (*cpp2::impl::assert_not_null(identity(c)) * *cpp2::impl::assert_not_null(identity(c))) {} - auto d {cpp2_new(0)}; + auto d {*cpp2::impl::assert_not_null(cpp2_new(0))}; if ((*cpp2::impl::assert_not_null(identity(d)) - *cpp2::impl::assert_not_null(identity(d)))) {} - auto e {cpp2_new(0)}; + auto e {*cpp2::impl::assert_not_null(cpp2_new(0))}; static_cast(cpp2::impl::is(e, (e))); - auto f {cpp2_new(0)}; + auto f {*cpp2::impl::assert_not_null(cpp2_new(0))}; static_cast(cpp2::impl::is>(f));// OK? - auto g {cpp2_new(0)}; + auto g {*cpp2::impl::assert_not_null(cpp2_new(0))}; for ( [[maybe_unused]] auto const& unnamed_param_1 : { *cpp2::impl::assert_not_null(identity(g)) + *cpp2::impl::assert_not_null(identity(g)) } ) {} - auto h {cpp2_new(0)}; + auto h {*cpp2::impl::assert_not_null(cpp2_new(0))}; while( *cpp2::impl::assert_not_null(identity(h)) + *cpp2::impl::assert_not_null(identity(h)) ) {} - auto i {cpp2_new(0)}; + auto i {*cpp2::impl::assert_not_null(cpp2_new(0))}; do {} while ( *cpp2::impl::assert_not_null(identity(i)) + *cpp2::impl::assert_not_null(identity(i))); - auto j {cpp2_new(0)}; - auto k {cpp2_new(0)}; + auto j {*cpp2::impl::assert_not_null(cpp2_new(0))}; + auto k {*cpp2::impl::assert_not_null(cpp2_new(0))}; static_cast([&] () -> int { auto&& _expr = *cpp2::impl::assert_not_null(identity(j)) + *cpp2::impl::assert_not_null(identity(j)); if (cpp2::impl::is(_expr, (*cpp2::impl::assert_not_null(identity(k)) + *cpp2::impl::assert_not_null(identity(k))))) { if constexpr( requires{0;} ) if constexpr( std::is_convertible_v ) return 0; else return int{}; else return int{}; } else return 0; } @@ -578,7 +578,7 @@ auto issue_313() -> void{ } // { -// a := new(0); +// a := new(0)*; // _ = :() identity(a$)* + identity(a$)*; // } } @@ -613,7 +613,7 @@ auto issue_683(auto const& args) -> void{ auto issue_825() -> void{ static_cast([](std::unique_ptr b) mutable -> auto { return f_copy(std::move(cpp2::move(b))); }); static_cast([](std::unique_ptr&& c) mutable -> auto { return f_copy(std::move(cpp2::move(c))); }); - static_cast([](auto&& d) mutable -> auto { return f_copy(CPP2_FORWARD(d)); }(cpp2_new(0))); + static_cast([](auto&& d) mutable -> auto { return f_copy(CPP2_FORWARD(d)); }(*cpp2::impl::assert_not_null(cpp2_new(0)))); } #line 120 "pure2-last-use.cpp2" @@ -730,10 +730,10 @@ int gi {0}; auto issue_857_9::g2() && -> void { f_inout(cpp2::move((*this)).c); } #line 373 "pure2-last-use.cpp2" - issue_869_0::issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2){} + issue_869_0::issue_869_0([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2){} #line 373 "pure2-last-use.cpp2" - auto issue_869_0::operator=([[maybe_unused]] std::unique_ptr&& unnamed_param_2) -> issue_869_0& { - return *this; } + auto issue_869_0::operator=([[maybe_unused]] cpp2::owning_reference&& unnamed_param_2) -> issue_869_0& { + return *this; } issue_869_0::issue_869_0([[maybe_unused]] issue_869_0 const& that){} @@ -781,13 +781,13 @@ issue_869_1::issue_869_1(issue_869_1 const& that) } #line 378 "pure2-last-use.cpp2" [[nodiscard]] auto issue_869_2() -> issue_869_2_ret{ - issue_869_1 res {}; CPP2_UFCS(set_i)(res, cpp2_new(0)); + issue_869_1 res {}; CPP2_UFCS(set_i)(res, *cpp2::impl::assert_not_null(cpp2_new(0))); #line 379 "pure2-last-use.cpp2" return res; } #line 380 "pure2-last-use.cpp2" auto issue_884() -> void{ static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) {} { {f_inout(x); } @@ -796,7 +796,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { f_copy(std::move(cpp2::move(x))); } @@ -807,7 +807,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { f_inout(x); } @@ -819,7 +819,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_copy(std::move(cpp2::move(x))); if (true) { static_cast(0); @@ -832,7 +832,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_copy(std::move(cpp2::move(x))); @@ -845,7 +845,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { static_cast(0); @@ -858,7 +858,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { static_cast(0); @@ -871,7 +871,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { static_cast(0); @@ -884,7 +884,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_copy(std::move(cpp2::move(x))); @@ -897,7 +897,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_copy(std::move(cpp2::move(x))); @@ -910,7 +910,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_inout(x); @@ -926,7 +926,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_inout(x); @@ -942,7 +942,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_inout(x); if (true) { f_copy(std::move(cpp2::move(x))); @@ -958,7 +958,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { if (true) { if (true) { @@ -971,7 +971,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { if (true) { if (true) { @@ -985,7 +985,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { } else { @@ -998,7 +998,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { f_copy(std::move(cpp2::move(x))); } @@ -1012,9 +1012,9 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { - auto y {cpp2_new(0)}; + auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_copy(std::move(cpp2::move(x))); f_copy(std::move(cpp2::move(y))); } @@ -1029,9 +1029,9 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { - auto y {cpp2_new(0)}; + auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) {} else { f_copy(std::move(cpp2::move(x))); @@ -1041,7 +1041,7 @@ auto issue_884() -> void{ else { if (true) { if (true) { - auto y {cpp2_new(0)}; + auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_copy(std::move(cpp2::move(y))); f_inout(x); } @@ -1051,9 +1051,9 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { - auto y {cpp2_new(0)}; + auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) {} else { f_copy(std::move(cpp2::move(x))); @@ -1061,7 +1061,7 @@ auto issue_884() -> void{ } } else { - auto y {cpp2_new(0)}; + auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { if (true) { f_copy(std::move(cpp2::move(x))); @@ -1075,13 +1075,13 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { f_copy(std::move(cpp2::move(x))); } else { if (true) { - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { f_inout(x); } @@ -1094,10 +1094,10 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { if (true) { - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { f_inout(x); } @@ -1113,7 +1113,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { f_inout(x); @@ -1127,7 +1127,7 @@ auto issue_884() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { if (true) { f_inout(x); @@ -1193,9 +1193,9 @@ auto issue_888_1([[maybe_unused]] std::string unnamed_param_1, move_only_functio #line 784 "pure2-last-use.cpp2" auto issue_890() -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; { -auto const& x{cpp2_new(0)}; +auto const& x{*cpp2::impl::assert_not_null(cpp2_new(0))}; // assert(identity_copy(x)* == 0); #line 787 "pure2-last-use.cpp2" if (cpp2::cpp2_default.is_active() && !(*cpp2::impl::assert_not_null(identity(x)) == 0) ) { cpp2::cpp2_default.report_violation(""); } @@ -1224,13 +1224,13 @@ auto enum_0() -> void{ } #line 806 "pure2-last-use.cpp2" auto enum_1() -> void{ - auto max_value {cpp2_new(0)}; - std::reference_wrapper const> min_value {cpp2::move(max_value)}; + auto max_value {*cpp2::impl::assert_not_null(cpp2_new(0))}; + std::reference_wrapper const> min_value {cpp2::move(max_value)}; // for (0) // do (copy x) // { - // v := new(identity_copy(x)); + // v := new(identity_copy(x))*; // if pred(v, min_value) { // min_value = std::ref(identity(v)); // Not using 'else' will never move 'v'. // } @@ -1239,21 +1239,21 @@ auto enum_1() -> void{ // } // } - auto y {cpp2_new(false)}; + auto y {*cpp2::impl::assert_not_null(cpp2_new(false))}; while( *cpp2::impl::assert_not_null(identity(y)) ) { - auto v {cpp2_new(0)}; + auto v {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_copy(std::move(cpp2::move(v))); } - auto z {cpp2_new(false)}; + auto z {*cpp2::impl::assert_not_null(cpp2_new(false))}; do { - auto v {cpp2_new(0)}; + auto v {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_copy(std::move(cpp2::move(v))); } while ( *cpp2::impl::assert_not_null(identity(z))); } #line 834 "pure2-last-use.cpp2" auto enum_2() -> void{ - auto umax {cpp2_new(0)}; + auto umax {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (pred(umax)) { } else {if (pred(umax)) { @@ -1299,14 +1299,14 @@ return std::move(p.value()); } #line 875 "pure2-last-use.cpp2" auto loops() -> void{ static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; for ( [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) f_inout(x); }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; for ( [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) { do @@ -1314,14 +1314,14 @@ auto loops() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; for ( [[maybe_unused]] auto const& unnamed_param_1 : { 0 } ) if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(get)(x)) ) { cpp2::cpp2_default.report_violation(""); } }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (true) { f_copy(std::move(cpp2::move(x))); } @@ -1337,10 +1337,10 @@ namespace captures { #line 915 "pure2-last-use.cpp2" auto f() -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_copy(std::move(cpp2::move(x))); auto id {[](auto const& x) mutable -> auto&& { return x; }}; - auto y {cpp2_new(0)}; + auto y {*cpp2::impl::assert_not_null(cpp2_new(0))}; if (cpp2::cpp2_default.is_active() && !(&cpp2::move(id)(y) == &y) ) { cpp2::cpp2_default.report_violation(""); } } @@ -1360,13 +1360,13 @@ auto f() -> void{ #line 940 "pure2-last-use.cpp2" auto g() -> void{ static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_copy(std::move(cpp2::move(x))); static_cast([_0 = std::array auto { return identity(x); }(0)>()]() mutable -> auto { return _0; });// Fails on Clang 12 (lambda in unevaluated context). }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_inout(cpp2::move(x)); // _ = :() -> int = (:() x$*)$(); }); @@ -1377,7 +1377,7 @@ auto g() -> void{ #line 956 "pure2-last-use.cpp2" auto loops_and_captures() -> void{ static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_copy(std::move(cpp2::move(x))); for ( [[maybe_unused]] auto const& unnamed_param_1 : { [](auto const& x) mutable -> auto { return x; } } ) @@ -1385,7 +1385,7 @@ auto loops_and_captures() -> void{ }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_copy(std::move(cpp2::move(x))); for ( @@ -1395,7 +1395,7 @@ auto loops_and_captures() -> void{ }); // _ = :() = { -// x := new(0); +// x := new(0)*; // for (:() x$*) // do (_) // { } @@ -1405,10 +1405,10 @@ auto loops_and_captures() -> void{ #line 994 "pure2-last-use.cpp2" auto skip_hidden_names() -> void{ static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_copy(std::move(cpp2::move(x))); { -auto x{cpp2_new(0)}; +auto x{*cpp2::impl::assert_not_null(cpp2_new(0))}; #line 999 "pure2-last-use.cpp2" f_copy(std::move(cpp2::move(x))); @@ -1417,10 +1417,10 @@ auto x{cpp2_new(0)}; }); // _ = :() = { -// x := new(0); +// x := new(0)*; // _ = :() = { // _ = x$; -// x := new(1); +// x := new(1)*; // _ = :() = { // _ = x$; // }; @@ -1429,8 +1429,8 @@ auto x{cpp2_new(0)}; static_cast([]() mutable -> void{ { -auto x{cpp2_new(0)}; - // x := new(0); +auto x{*cpp2::impl::assert_not_null(cpp2_new(0))}; + // x := new(0)*; // f_copy(x); // for (0) // do (copy x) @@ -1443,7 +1443,7 @@ auto x{cpp2_new(0)}; }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_inout(x); { f_copy(std::move(cpp2::move(x))); @@ -1453,10 +1453,10 @@ auto x{cpp2_new(0)}; }); static_cast([]() mutable -> void{ - auto x {cpp2_new(0)}; + auto x {*cpp2::impl::assert_not_null(cpp2_new(0))}; f_copy(std::move(cpp2::move(x))); static_cast([]() mutable -> void{ - static_assert(std::is_same_v>); + static_assert(std::is_same_v>); using captures::x; f_inout(x); }); diff --git a/regression-tests/test-results/pure2-new-basics.cpp2.output b/regression-tests/test-results/pure2-new-basics.cpp2.output index 1be264804..cb7037ccc 100644 --- a/regression-tests/test-results/pure2-new-basics.cpp2.output +++ b/regression-tests/test-results/pure2-new-basics.cpp2.output @@ -1,2 +1,3 @@ -pure2-new-basics.cpp2... ok (all Cpp2, passes safety checks) +pure2-new-basics.cpp2... +pure2-new-basics.cpp2(40,9): error: invalid statement encountered inside a compound-statement (at 'move_test')