From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10151 invoked by alias); 30 Oct 2013 18:45:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 10121 invoked by uid 89); 30 Oct 2013 18:45:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_JMF_BL autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 30 Oct 2013 18:45:30 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id AAB98268AE8D; Wed, 30 Oct 2013 19:45:27 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lDXTAjMiLZrf; Wed, 30 Oct 2013 19:45:27 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 5637C268AE20; Wed, 30 Oct 2013 19:45:27 +0100 (CET) From: Eric Botcazou To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: Re: C++ PATCH to deal with trivial but non-callable [cd]tors Date: Wed, 30 Oct 2013 19:22:00 -0000 Message-ID: <2551943.bJVO2p0GTe@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) In-Reply-To: <5271317E.1010503@redhat.com> References: <52680FD9.7040302@redhat.com> <5471599.klPL436CBS@polaris> <5271317E.1010503@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-SW-Source: 2013-10/txt/msg02588.txt.bz2 > > +/* Return whether DECL, a method of a C++ TYPE, is trivial, that is to > > say + doesn't do anything for the objects of TYPE. */ > > + > > +static bool > > +is_trivial_method (const_tree decl, const_tree type) > > +{ > > + if (cpp_check (decl, IS_CONSTRUCTOR) && !TYPE_NEEDS_CONSTRUCTING > > (type)) + return true; > > This will tell you whether decl is a constructor for a type with some > non-trivial constructor, but not whether decl itself is non-trivial. I think that's good enough though, in practice we only need to eliminate constructors/destructors for POD types. As soon as there is one non-trivial method, the game is essentially over. > I think a good way to check for any non-trivial methods would be to > check trivial_type_p in the front end and then see if there are any > !DECL_ARTIFICIAL decls in TYPE_METHODS. That sounds interesting indeed, thanks for the tip. I was initially reluctant to call into the front-end because of side-effects, but the various predicates in tree.c seem fine in this respect. -- Eric Botcazou