On Tue, Jan 26, 2016 at 12:44 PM, Marc Glisse <marc.gli...@inria.fr> wrote: > On Tue, 26 Jan 2016, H.J. Lu wrote: > >> On Tue, Jan 26, 2016 at 12:23 PM, Marc Glisse <marc.gli...@inria.fr> >> wrote: >>> >>> On Tue, 26 Jan 2016, H.J. Lu wrote: >>> >>>> On Tue, Jan 26, 2016 at 11:27 AM, Jason Merrill <ja...@redhat.com> >>>> 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.