From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47650 invoked by alias); 26 Jan 2016 21:21:56 -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 47636 invoked by uid 89); 26 Jan 2016 21:21:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=POD, Hx-languages-length:2107, pod X-HELO: mail-qk0-f172.google.com Received: from mail-qk0-f172.google.com (HELO mail-qk0-f172.google.com) (209.85.220.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 26 Jan 2016 21:21:54 +0000 Received: by mail-qk0-f172.google.com with SMTP id x1so68702568qkc.1 for ; Tue, 26 Jan 2016 13:21:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=dSNPfnrPwYptSWkP7S2/pUaNMVai+oF2SedZhfbJasQ=; b=VbdDXDmE9i9PJz6WbSAstk5X+626pAxbi3MvNkX56TO8gftVcReROMi7h8c/W3sv/c gcszXC0Zca5ga3vBPFs075UCoghRpxL9w1VYK/Riyv2ch7Ow2kpm0kpX/4cD2G2van8C uUKWZ1ToKZWnIiJTl33m0CoUnBC+dqiZaQQDf2RZD6fl0jnPjIllH1JkDXHW1Ynxt7Lw /cQb+a2T3c6NMY/IRYfKvleaTt0lweT9ZDIsLuBuOnC64SGCh5hJAWwwJt4vSHd6LD/G BNDIVf9mjuaaTk2sbQfgS/U8rrVmtG6UeVwvJXjVhrrwCsrWeRET5dn5MvtX9/5lZS24 p4Nw== X-Gm-Message-State: AG10YOSSohq7zNnd0Zmtqk1HamwQMRxCNCZ65OKE/a/T3JwlBvvcUa9wPxL1qLyiHG4FPd+Nxv3eXpUGNAa3pg== MIME-Version: 1.0 X-Received: by 10.55.77.2 with SMTP id a2mr30977137qkb.108.1453843312126; Tue, 26 Jan 2016 13:21:52 -0800 (PST) Received: by 10.55.4.210 with HTTP; Tue, 26 Jan 2016 13:21:52 -0800 (PST) In-Reply-To: References: <20151209213118.GC317@x4> <566C346B.8030601@redhat.com> <20151212152731.GB18720@tucnak.redhat.com> <566F23AE.6070604@redhat.com> <566F2A0B.4010102@redhat.com> <56A7C8AC.8070204@redhat.com> Date: Tue, 26 Jan 2016 21:21:00 -0000 Message-ID: Subject: Re: PING^1: [PATCH] Add TYPE_EMPTY_RECORD for C++ empty class From: "H.J. Lu" To: GCC Patches Cc: Jason Merrill , Jakub Jelinek , Richard Biener , Markus Trippelsdorf Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-01/txt/msg02043.txt.bz2 On Tue, Jan 26, 2016 at 12:44 PM, Marc Glisse wrote: > On Tue, 26 Jan 2016, H.J. Lu wrote: > >> On Tue, Jan 26, 2016 at 12:23 PM, Marc Glisse >> wrote: >>> >>> On Tue, 26 Jan 2016, H.J. Lu wrote: >>> >>>> On Tue, Jan 26, 2016 at 11:27 AM, Jason Merrill >>>> wrote: >>>>> >>>>> >>>>> On 12/14/2015 05:08 PM, H.J. Lu wrote: >>>>>> >>>>>> >>>>>> >>>>>> + if (abi_version_at_least (10)) >>>>>> + TYPE_EMPTY_RECORD (t) = is_really_empty_class (t); >>>>> >>>>> >>>>> >>>>> >>>>> This should use is_empty_class or CLASSTYPE_EMPTY_P. We don't want to >>>>> change how classes with just a vptr are passed. >>>>> >>>>> Otherwise, it looks OK to me. >>>> >>>> >>>> >>>> Is true_type an empty class here? is_empty_class returns false >>>> on this: >>> >>> >>> >>> It isn't empty in the usual C++ sense (we can't apply the empty base >>> optimization to something that derives from it, for instance), or the one >>> described in the itanium ABI (the relevant one here I guess). On the >>> other >>> hand, it is rather useless to pass it by value, so a different notion of >> >> >> llvm/clang treats it as empty class and I think it should be treated >> as "empty" class. > > > Is it still empty if there are several empty members? Is there a clear > definition somewhere of what empty means? I guess it makes sense to > recursively allow "empty" members for this purpose. Like this: /* Returns true if TYPE is POD for the purpose of layout and an empty class or an class with empty classes. */ static bool is_empty_record (tree type) { if (type == error_mark_node) return false; if (!CLASS_TYPE_P (type)) return false; if (CLASSTYPE_NON_LAYOUT_POD_P (type)) return false; gcc_assert (COMPLETE_TYPE_P (type)); if (CLASSTYPE_EMPTY_P (type)) return true; tree field; for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) if (TREE_CODE (field) == FIELD_DECL && !DECL_ARTIFICIAL (field) && !is_empty_record (TREE_TYPE (field))) return false; return true; } -- H.J.