From d0986eeb365cfa20f471843d2bff58e572a9b54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Mon, 11 Dec 2023 20:33:31 -0400 Subject: [PATCH] test: discard unused parameters but not `void` expressions --- ...pure2-bugfix-for-deducible-parameters.cpp2 | 17 ++++--- .../pure2-bugfix-for-dependent-types.cpp2 | 8 ++-- .../pure2-bugfix-for-deducible-parameters.cpp | 45 +++++++++---------- .../pure2-bugfix-for-dependent-types.cpp | 8 ++-- 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/regression-tests/pure2-bugfix-for-deducible-parameters.cpp2 b/regression-tests/pure2-bugfix-for-deducible-parameters.cpp2 index dbe01dc214..a3b4c76284 100644 --- a/regression-tests/pure2-bugfix-for-deducible-parameters.cpp2 +++ b/regression-tests/pure2-bugfix-for-deducible-parameters.cpp2 @@ -1,5 +1,4 @@ -// Dependent, non-deducible parameters -// are wrapped like non-dependent parameters. +// Dependent, non-deducible parameters are wrapped like non-dependent parameters. init: (out x: std::integral_constant) = { x = (); } init: (out x: std::integral_constant, _: T) = { x = (); } id: (x: std::integral_constant) -> forward _ = x; @@ -13,21 +12,21 @@ main: () = { assert(id(z)& == z&); // Deducible parameters. - _ = :v = 0; - _ = : (x: std::vector) = {}(:std::vector = ()); - _ = : (x: std::vector>) = {}(:std::vector> = ()); + _ = :v = 0; + : (_: std::vector) = {}(:std::vector = ()); + : (_: std::vector>) = {}(:std::vector> = ()); // _ = : (x: std::pair, y: U) = {}(:std::pair = (0, 0), z); // Blocked on #727. - _ = : (x: std::array, y: U) = {}(:std::array = (), z); + : (_: std::array, _: U) = {}(:std::array = (), z); init(out z, z); id(z, z); // Test that these are emitted unwrapped in case they are deducible. - (copy f := : (x: std::vector>) = {}) + (copy f := : (_: std::vector>) = {}) static_assert(!std::is_invocable_v>, "`T` is non-deducible."); - (copy f := : (x: std::vector>) = {}) + (copy f := : (_: std::vector>) = {}) static_assert(std::is_invocable_v>>, "`T` is deducible."); } v: type = { - operator=: (out this, x: T) = { } + operator=: (out this, _: T) = { } } diff --git a/regression-tests/pure2-bugfix-for-dependent-types.cpp2 b/regression-tests/pure2-bugfix-for-dependent-types.cpp2 index be0e0838b7..1b1da09673 100644 --- a/regression-tests/pure2-bugfix-for-dependent-types.cpp2 +++ b/regression-tests/pure2-bugfix-for-dependent-types.cpp2 @@ -70,10 +70,10 @@ main: () = { _ = :() = { _ = :() = { _ = : () = { _ = :() = { _ = :T::value_type = (); }; }; }; }; _ = :() = { _ = : () = { _ = :() = { _ = :() = { _ = :T::value_type = (); }; }; }; }; _ = : () = { _ = :() = { _ = :() = { _ = :() = { _ = :T::value_type = (); }; }; }; }; - _ = : () = { _ = :() = { _ = :() = { _ = :(x: T::value_type) = {}; }; }; }; - _ = : () = { _ = :() = { _ = :(x: T::value_type) = { _ = :() = {}; }; }; }; - _ = : () = { _ = :(x: T::value_type) = { _ = :() = { _ = :() = {}; }; }; }; - _ = : (x: T::value_type) = { _ = :() = { _ = :() = { _ = :() = {}; }; }; }; + _ = : () = { _ = :() = { _ = :() = { _ = :(_: T::value_type) = {}; }; }; }; + _ = : () = { _ = :() = { _ = :(_: T::value_type) = { _ = :() = {}; }; }; }; + _ = : () = { _ = :(_: T::value_type) = { _ = :() = { _ = :() = {}; }; }; }; + _ = : (_: T::value_type) = { _ = :() = { _ = :() = { _ = :() = {}; }; }; }; // Lookup. { diff --git a/regression-tests/test-results/pure2-bugfix-for-deducible-parameters.cpp b/regression-tests/test-results/pure2-bugfix-for-deducible-parameters.cpp index 5bc3729eb2..a1c6fe5e0c 100644 --- a/regression-tests/test-results/pure2-bugfix-for-deducible-parameters.cpp +++ b/regression-tests/test-results/pure2-bugfix-for-deducible-parameters.cpp @@ -8,16 +8,15 @@ #line 1 "pure2-bugfix-for-deducible-parameters.cpp2" -#line 31 "pure2-bugfix-for-deducible-parameters.cpp2" +#line 30 "pure2-bugfix-for-deducible-parameters.cpp2" template class v; //=== Cpp2 type definitions and function declarations =========================== #line 1 "pure2-bugfix-for-deducible-parameters.cpp2" -// Dependent, non-deducible parameters -// are wrapped like non-dependent parameters. -#line 3 "pure2-bugfix-for-deducible-parameters.cpp2" +// Dependent, non-deducible parameters are wrapped like non-dependent parameters. +#line 2 "pure2-bugfix-for-deducible-parameters.cpp2" template auto init(cpp2::out> x) -> void; template auto init(cpp2::out> x, [[maybe_unused]] T const& unnamed_param_2) -> void; template [[nodiscard]] auto id(cpp2::in> x) -> auto&&; @@ -25,15 +24,15 @@ template auto id(cpp2::in auto main() -> int; -#line 31 "pure2-bugfix-for-deducible-parameters.cpp2" +#line 30 "pure2-bugfix-for-deducible-parameters.cpp2" template class v { - public: explicit v(T const& x); -#line 32 "pure2-bugfix-for-deducible-parameters.cpp2" - public: auto operator=(T const& x) -> v& ; + public: explicit v([[maybe_unused]] T const& unnamed_param_2); +#line 31 "pure2-bugfix-for-deducible-parameters.cpp2" + public: auto operator=([[maybe_unused]] T const& unnamed_param_2) -> v& ; public: v(v const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(v const&) -> void = delete; -#line 33 "pure2-bugfix-for-deducible-parameters.cpp2" +#line 32 "pure2-bugfix-for-deducible-parameters.cpp2" }; @@ -41,7 +40,7 @@ template class v { #line 1 "pure2-bugfix-for-deducible-parameters.cpp2" -#line 3 "pure2-bugfix-for-deducible-parameters.cpp2" +#line 2 "pure2-bugfix-for-deducible-parameters.cpp2" template auto init(cpp2::out> x) -> void{x.construct(); } template auto init(cpp2::out> x, [[maybe_unused]] T const& unnamed_param_2) -> void{x.construct(); } template [[nodiscard]] auto id(cpp2::in> x) -> auto&& { return x; } @@ -55,33 +54,33 @@ auto main() -> int{ cpp2::Default.expects(&id(z.value()) == &z.value(), ""); // Deducible parameters. - static_cast(v{0}); - static_cast([](std::vector const& x) mutable -> void{}(std::vector{})); - static_cast([](std::vector> const& x) mutable -> void{}(std::vector>{})); + static_cast(v{ 0}); + []([[maybe_unused]] std::vector const& unnamed_param_1) mutable -> void{}(std::vector{}); + []([[maybe_unused]] std::vector> const& unnamed_param_1) mutable -> void{}(std::vector>{}); // _ = : (x: std::pair, y: U) = {}(:std::pair = (0, 0), z); // Blocked on #727. - static_cast([](std::array const& x, U const& y) mutable -> void{}(std::array{}, z.value())); + []([[maybe_unused]] std::array const& unnamed_param_1, [[maybe_unused]] U const& unnamed_param_2) mutable -> void{}(std::array{}, z.value()); init(cpp2::out(&z.value()), z.value()); id(z.value(), std::move(z.value())); { -auto f = [](std::vector> const& x) mutable -> void{}; +auto f = []([[maybe_unused]] std::vector> const& unnamed_param_1) mutable -> void{}; // Test that these are emitted unwrapped in case they are deducible. -#line 26 "pure2-bugfix-for-deducible-parameters.cpp2" +#line 25 "pure2-bugfix-for-deducible-parameters.cpp2" static_assert(!(std::is_invocable_v>), "`T` is non-deducible."); } { -auto f = [](std::vector> const& x) mutable -> void{}; +auto f = []([[maybe_unused]] std::vector> const& unnamed_param_1) mutable -> void{}; -#line 28 "pure2-bugfix-for-deducible-parameters.cpp2" +#line 27 "pure2-bugfix-for-deducible-parameters.cpp2" static_assert(std::is_invocable_v>>, "`T` is deducible."); } -#line 29 "pure2-bugfix-for-deducible-parameters.cpp2" +#line 28 "pure2-bugfix-for-deducible-parameters.cpp2" } -#line 32 "pure2-bugfix-for-deducible-parameters.cpp2" - template v::v(T const& x){} -#line 32 "pure2-bugfix-for-deducible-parameters.cpp2" - template auto v::operator=(T const& x) -> v& { +#line 31 "pure2-bugfix-for-deducible-parameters.cpp2" + template v::v([[maybe_unused]] T const& unnamed_param_2){} +#line 31 "pure2-bugfix-for-deducible-parameters.cpp2" + template auto v::operator=([[maybe_unused]] T const& unnamed_param_2) -> v& { return *this; } diff --git a/regression-tests/test-results/pure2-bugfix-for-dependent-types.cpp b/regression-tests/test-results/pure2-bugfix-for-dependent-types.cpp index 2fd6c6f1b3..2806cfc1ba 100644 --- a/regression-tests/test-results/pure2-bugfix-for-dependent-types.cpp +++ b/regression-tests/test-results/pure2-bugfix-for-dependent-types.cpp @@ -102,10 +102,10 @@ auto main() -> int{ static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast(typename T::value_type{}); }); }); }); }); static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast(typename T::value_type{}); }); }); }); }); static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast(typename T::value_type{}); }); }); }); }); - static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([](cpp2::in x) mutable -> void{}); }); }); }); - static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([](cpp2::in x) mutable -> void{static_cast([]() mutable -> void{}); }); }); }); - static_cast([]() mutable -> void{static_cast([](cpp2::in x) mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{}); }); }); }); - static_cast([](cpp2::in x) mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{}); }); }); }); + static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]([[maybe_unused]] cpp2::in unnamed_param_1) mutable -> void{}); }); }); }); + static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]([[maybe_unused]] cpp2::in unnamed_param_1) mutable -> void{static_cast([]() mutable -> void{}); }); }); }); + static_cast([]() mutable -> void{static_cast([]([[maybe_unused]] cpp2::in unnamed_param_1) mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{}); }); }); }); + static_cast([]([[maybe_unused]] cpp2::in unnamed_param_1) mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{static_cast([]() mutable -> void{}); }); }); }); // Lookup. {