From: Marek Polacek Date: Fri, 3 Feb 2023 18:45:10 +0000 (-0500) Subject: c++: Add fixed test [PR101071] X-Git-Tag: basepoints/gcc-14~1515 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60fca1802a25034f49fa1e3769b3a5656f392e89;p=thirdparty%2Fgcc.git 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 --git a/gcc/testsuite/g++.dg/cpp0x/variadic-alias8.C b/gcc/testsuite/g++.dg/cpp0x/variadic-alias8.C new file mode 100644 index 000000000000..1d317ef84385 --- /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() {}