From be464161b4ae128681958d94aa460531cf30e0a4 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 18 May 2020 13:50:39 -0400 Subject: [PATCH] c++: Add test for c++/95143 Already fixed by r10-8124-gceae6a13366d9646e172fc943fe8e221b70f0920. PR c++/95143 * g++.dg/cpp0x/sfinae66.C: New test. --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/sfinae66.C | 32 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/sfinae66.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 320095c49ae..008e4483169 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-05-18 Marek Polacek + + PR c++/95143 + * g++.dg/cpp0x/sfinae66.C: New test. + 2020-05-18 Uroš Bizjak PR target/95169 diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae66.C b/gcc/testsuite/g++.dg/cpp0x/sfinae66.C new file mode 100644 index 00000000000..49067cd35d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae66.C @@ -0,0 +1,32 @@ +// PR c++/95143 +// { dg-do compile { target c++11 } } + +struct false_type { + static constexpr bool value = false; +}; + +struct true_type{ + static constexpr bool value = true; +}; + +template +T&& declval() noexcept; + +template +struct is_static_castable : false_type +{}; +template +struct is_static_castable(declval()))> : true_type +{}; + +class Base { }; +struct A { }; +class B: public Base { }; + +int main() +{ + constexpr auto canCast = is_static_castable::value; + static_assert(!canCast, ""); + constexpr auto canCast2 = is_static_castable::value; + static_assert(canCast2, ""); +} -- 2.30.2