From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1734) id D04393858D20; Fri, 3 Feb 2023 18:50:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D04393858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675450226; bh=GwJcKvhY9YdhIos8SmP7OerHpdrQrfdSp9l9FFFFgLQ=; h=From:To:Subject:Date:From; b=QWvDU704guY2uggcUPq/T7jXUN70N8UIXdJHwNC/rk32Fxcshr2dwOS/k11ZllTKu B/1i+SGdabuDSEhbiyH2Mzf241QK0EVsAHnJsoiCbMe2nBNsmbnRsJuoG/GBXzzNyr Hra3JPm1D5xG47fa8aYXiD8rMEdtMmW+wfNmIRr0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marek Polacek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5692] c++: Add fixed test [PR101071] X-Act-Checkin: gcc X-Git-Author: Marek Polacek X-Git-Refname: refs/heads/trunk X-Git-Oldrev: f0065f207cf19cd960b33d961472c6d69514336f X-Git-Newrev: 60fca1802a25034f49fa1e3769b3a5656f392e89 Message-Id: <20230203185026.D04393858D20@sourceware.org> Date: Fri, 3 Feb 2023 18:50:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:60fca1802a25034f49fa1e3769b3a5656f392e89 commit r13-5692-g60fca1802a25034f49fa1e3769b3a5656f392e89 Author: Marek Polacek Date: Fri Feb 3 13:45:10 2023 -0500 c++: Add fixed test [PR101071] As a happy accident, this was fixed by the recent r13-2978. PR c++/101071 gcc/testsuite/ChangeLog: * g++.dg/cpp0x/variadic-alias8.C: New test. Diff: --- gcc/testsuite/g++.dg/cpp0x/variadic-alias8.C | 95 ++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-alias8.C b/gcc/testsuite/g++.dg/cpp0x/variadic-alias8.C new file mode 100644 index 00000000000..1d317ef8438 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-alias8.C @@ -0,0 +1,95 @@ +// PR c++/101071 +// { dg-do compile { target c++11 } } +// { dg-additional-options "-fno-elide-constructors -O2" } + +// Like variadic-alias2.C, just different options. + +template +struct list {}; + +struct nil; + +//////////////////////////////////////////////////////////////////////////////// + +template +struct number { + constexpr /*implicit*/ operator int() const { return n; } + using type = number; +}; + +using false_ = number<0>; +using true_ = number<1>; + +static_assert(!false_{}, ""); +static_assert(true_{}, ""); + +template using numbers = list...>; + +//////////////////////////////////////////////////////////////////////////////// + +template +struct less_impl; + +template +struct less_impl, number> + : number<(lhs < rhs)> {}; + +template using less = typename less_impl::type; + +//////////////////////////////////////////////////////////////////////////////// + +template +struct sum_impl { + static_assert(sizeof...(vs) == 0, "see specialization"); + using type = v0; +}; + +template +struct sum_impl, number, vs...> + : sum_impl, vs...> {}; + +template using sum = typename sum_impl::type; + +//////////////////////////////////////////////////////////////////////////////// + +template +struct conditional_impl { + static_assert(num{}, "see specialization"); + + template + using type = T; +}; + +template<> +struct conditional_impl { + template + using type = F; +}; + +template +using conditional = typename conditional_impl::template type; + +//////////////////////////////////////////////////////////////////////////////// + +template +struct min_filter_impl; + +template +struct min_filter_impl> { + template + using count_better_mins = sum...>; + + using type = list, nil, nums>...>; +}; + +template using min_filter = typename min_filter_impl::type; + +//////////////////////////////////////////////////////////////////////////////// + +void test_min_filter() { + using computed = min_filter>; + using expected = list, nil, number<2>>; + (void)(computed{} = expected{});// compiles for identical types +} + +int main() {}