From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 8EF3C383602B; Tue, 10 May 2022 08:20:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EF3C383602B MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10642] c++: Fix __is_*constructible/assignable for templates [PR102305] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: c7b00fbc469bc9c0a486b48bc349dba13881241e X-Git-Newrev: 269c6ed92a7dcfdacfa4a7ade2dc0616928b9b9b Message-Id: <20220510082038.8EF3C383602B@sourceware.org> Date: Tue, 10 May 2022 08:20:38 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 May 2022 08:20:38 -0000 https://gcc.gnu.org/g:269c6ed92a7dcfdacfa4a7ade2dc0616928b9b9b commit r10-10642-g269c6ed92a7dcfdacfa4a7ade2dc0616928b9b9b Author: Jakub Jelinek Date: Tue Sep 14 16:55:04 2021 +0200 c++: Fix __is_*constructible/assignable for templates [PR102305] is_xible_helper returns error_mark_node (i.e. false from the traits) for abstract classes by testing ABSTRACT_CLASS_TYPE_P (to) early. Unfortunately, as the testcase shows, that doesn't work on class templates that haven't been instantiated yet, ABSTRACT_CLASS_TYPE_P for them is false until it is instantiated, which is done when the routine later constructs a dummy object with that type. The following patch fixes this by calling complete_type first, so that ABSTRACT_CLASS_TYPE_P test will work properly, while keeping the handling of arrays with unknown bounds, or incomplete types where it is done currently. 2021-09-14 Jakub Jelinek PR c++/102305 * method.c (is_xible_helper): Call complete_type on to. * g++.dg/cpp0x/pr102305.C: New test. (cherry picked from commit f008fd3a480e3718436156697ebe7eeb47841457) Diff: --- gcc/cp/method.c | 1 + gcc/testsuite/g++.dg/cpp0x/pr102305.C | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/gcc/cp/method.c b/gcc/cp/method.c index bfd1004dcaa..746a75bef3d 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1877,6 +1877,7 @@ constructible_expr (tree to, tree from) static tree is_xible_helper (enum tree_code code, tree to, tree from, bool trivial) { + to = complete_type (to); deferring_access_check_sentinel acs (dk_no_deferred); if (VOID_TYPE_P (to) || ABSTRACT_CLASS_TYPE_P (to) || (from && FUNC_OR_METHOD_TYPE_P (from) diff --git a/gcc/testsuite/g++.dg/cpp0x/pr102305.C b/gcc/testsuite/g++.dg/cpp0x/pr102305.C new file mode 100644 index 00000000000..e63adcf5364 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr102305.C @@ -0,0 +1,39 @@ +// PR c++/102305 +// { dg-do compile { target c++11 } } + +namespace std +{ + template + struct integral_constant + { + static constexpr _Tp value = __v; + typedef integral_constant<_Tp, __v> type; + }; + + template + constexpr _Tp integral_constant<_Tp, __v>::value; + + typedef integral_constant true_type; + typedef integral_constant false_type; + + template + using bool_constant = integral_constant; + + template + struct is_constructible + : public bool_constant<__is_constructible(_Tp, _Args...)> + { + }; +} + +template +struct A { + virtual ~A() = 0; +}; + +struct B { + virtual ~B() = 0; +}; + +static_assert(!std::is_constructible >::value, ""); +static_assert(!std::is_constructible::value, "");