From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 0472238618DF for ; Sat, 24 Oct 2020 00:00:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0472238618DF Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-339-46nyPx8pNqGlgc0UxAayEg-1; Fri, 23 Oct 2020 20:00:28 -0400 X-MC-Unique: 46nyPx8pNqGlgc0UxAayEg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0ED11084C80; Sat, 24 Oct 2020 00:00:27 +0000 (UTC) Received: from redhat.com (ovpn-116-39.rdu2.redhat.com [10.10.116.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06A4A5D9CC; Sat, 24 Oct 2020 00:00:26 +0000 (UTC) Date: Fri, 23 Oct 2020 20:00:25 -0400 From: Marek Polacek To: Ville Voutilainen Cc: gcc-patches List , libstdc++ , Jason Merrill Subject: Re: [PATCH] g++, libstdc++: implement __is_nothrow_{constructible, assignable} Message-ID: <20201024000025.GP3628@redhat.com> References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-14.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Oct 2020 00:00:36 -0000 On Sat, Oct 24, 2020 at 02:32:37AM +0300, Ville Voutilainen via Gcc-patches wrote: > Finishing testing on Linux-PPC64. Ok for trunk if tests pass? > > 2020-10-24 Ville Voutilainen > > gcc/c-family/ChangeLog: > > Implement __is_nothrow_{constructible,assignable} > * c-common.c (__is_nothrow_assignable): New. > (__is_nothrow_constructible): Likewise. > * c-common.h (RID_IS_NOTHROW_ASSIGNABLE): New. > (RID_IS_NOTHROW_CONSTRUCTIBLE): Likewise. > > gcc/cp/ChangeLog: > > Implement __is_nothrow_{constructible,assignable} > * cp-tree.h (CPTK_IS_NOTHROW_ASSIGNABLE): New. > (CPTK_IS_NOTHROW_CONSTRUCTIBLE): Likewise. > (is_nothrow_xible): Likewise. > * method.c (__is_nothrow_xible): New. > * parser.c (cp_parser_primary_expression): Handle the new RID_*. > (cp_parser_trait_expr): Likewise. > * semantics.c (trait_expr_value): Handle the new RID_*. > (finish_trait_expr): Likewise. > > libstdc++-v3/ChangeLog: > > Implement __is_nothrow_{constructible,assignable} > * include/std/type_traits (__is_nt_constructible_impl): Remove. > (__is_nothrow_constructible_impl): Adjust. > (is_nothrow_default_constructible): Likewise. > (__is_nt_assignable_impl): Remove. > (__is_nothrow_assignable_impl): Adjust. > diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c > index e16ca3894bc..098a36e4d67 100644 > --- a/gcc/c-family/c-common.c > +++ b/gcc/c-family/c-common.c > @@ -527,6 +527,8 @@ const struct c_common_resword c_common_reswords[] = > { "while", RID_WHILE, 0 }, > { "__is_assignable", RID_IS_ASSIGNABLE, D_CXXONLY }, > { "__is_constructible", RID_IS_CONSTRUCTIBLE, D_CXXONLY }, > + { "__is_nothrow_assignable", RID_IS_NOTHROW_ASSIGNABLE, D_CXXONLY }, > + { "__is_nothrow_constructible", RID_IS_NOTHROW_CONSTRUCTIBLE, D_CXXONLY }, > > /* C++ transactional memory. */ > { "synchronized", RID_SYNCHRONIZED, D_CXX_OBJC | D_TRANSMEM }, > diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h > index 3d96092a297..24a4a8e7fe3 100644 > --- a/gcc/c-family/c-common.h > +++ b/gcc/c-family/c-common.h > @@ -176,6 +176,7 @@ enum rid > RID_IS_TRIVIALLY_COPYABLE, > RID_IS_UNION, RID_UNDERLYING_TYPE, > RID_IS_ASSIGNABLE, RID_IS_CONSTRUCTIBLE, > + RID_IS_NOTHROW_ASSIGNABLE, RID_IS_NOTHROW_CONSTRUCTIBLE, > > /* C++11 */ > RID_CONSTEXPR, RID_DECLTYPE, RID_NOEXCEPT, RID_NULLPTR, RID_STATIC_ASSERT, > diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h > index 5c06ac3789e..1ce20989e13 100644 > --- a/gcc/cp/cp-tree.h > +++ b/gcc/cp/cp-tree.h > @@ -1323,7 +1323,9 @@ enum cp_trait_kind > CPTK_IS_UNION, > CPTK_UNDERLYING_TYPE, > CPTK_IS_ASSIGNABLE, > - CPTK_IS_CONSTRUCTIBLE > + CPTK_IS_CONSTRUCTIBLE, > + CPTK_IS_NOTHROW_ASSIGNABLE, > + CPTK_IS_NOTHROW_CONSTRUCTIBLE > }; > > /* The types that we are processing. */ > @@ -6752,6 +6754,7 @@ extern void use_thunk (tree, bool); > extern bool trivial_fn_p (tree); > extern tree forward_parm (tree); > extern bool is_trivially_xible (enum tree_code, tree, tree); > +extern bool is_nothrow_xible (enum tree_code, tree, tree); > extern bool is_xible (enum tree_code, tree, tree); > extern tree get_defaulted_eh_spec (tree, tsubst_flags_t = tf_warning_or_error); > extern bool maybe_explain_implicit_delete (tree); > diff --git a/gcc/cp/method.c b/gcc/cp/method.c > index 6e4c5f7e83b..2ffc86cbd81 100644 > --- a/gcc/cp/method.c > +++ b/gcc/cp/method.c > @@ -1933,6 +1933,21 @@ is_trivially_xible (enum tree_code code, tree to, tree from) > return !nt; > } > > +/* Returns true iff TO is nothrow assignable (if CODE is MODIFY_EXPR) or > + constructible (otherwise) from FROM, which is a single type for > + assignment or a list of types for construction. */ > + > +bool > +is_nothrow_xible (enum tree_code code, tree to, tree from) > +{ > + tree expr; > + expr = is_xible_helper (code, to, from, /*trivial*/false); tree expr = is_xible_helper (code, to, from, /*trivial*/false); would be nicer, otherwise the front-end changes look fine, thanks. Marek