On Wed, Apr 08, 2015 at 06:32:29PM +0200, Jan Hubicka wrote: > > On Wed, Apr 08, 2015 at 06:22:10PM +0200, Jan Hubicka wrote: > > > > On 04/08/2015 06:02 AM, Jakub Jelinek wrote: > > > > > (cp_build_qualified_type_real): Use check_base_type. Build a > > > > > variant and copy over even TYPE_CONTEXT and > > > > > TYPE_ALIGN/TYPE_USER_ALIGN if any of those are different. > > > > > > > > This seems wrong. If there is an array with the same name, > > > > attributes and element type, it should have the same alignment; if > > > > > > One of problems is that cp_build_qualified_type rebuilds the array from > > > scratch and never copies the attribute list around (as oposed to > > > build_qualified_type that just memcpy the type node) > > > > As I said earlier, TYPE_ATTRIBUTES is NULL here anyway, because the > > attributes hang in DECL_ATTRIBUTES of TYPE_DECL. And, except for > > config/sol2.c (which looks wrong), nothing ever calls lookup_attribute for > > "aligned" anyway, the user aligned stuff is encoded in TYPE_USER_ALIGN > > and/or DECL_USER_ALIGN and TYPE_ALIGN/DECL_ALIGN. > > This is interesting too. I did know that alignment is "lowered" into > TYPE_USER_ALIGN/TYPE_ALIGN values, but there is a lot of other code > that looks for type attributes by searching TYPE_ATTRIBUTES, not > DECL_ATTRIBUTES > of TYPE_DECL (such as nonnul_arg_p in tree-vrp) or alloc_object_size. > Does it mean that those attributes are ignored for C++ produced types?
I don't think this has anything to do with C++. c-common.c has an attribute table, for each attribute it has 3 flags, whether a decl is required, type is required and/or fn type is required, and that determines to what the attributes go. These flags have the following combinations (decl/type/fntype # of attributes): TFF 51 (i.e. decl required) FTT 12 (i.e. function type required) FTF 9 (i.e. some type required) FFF 7 (applies to both types and decls) Which means most of the attributes require a decl and thus go into DECL_ATTRIBUTES, then some require function types and go to the TYPE_ATTRIBUTES of the function, then others go solely to TYPE_ATTRIBUTES. The last row are attributes that don't really care where they apply to, and that is { "packed", 0, 0, false, false, false, { "unused", 0, 0, false, false, false, { "transparent_union", 0, 0, false, false, false, { "aligned", 0, 1, false, false, false, { "deprecated", 0, 1, false, false, false, { "visibility", 1, 1, false, false, false, { "warn_unused", 0, 0, false, false, false, where the first 6 really don't care about what is stored in {TYPE,DECL}_ATTRIBUTES because the attributes are encoded differently in generic, and the last one sounds like a mistake (perhaps one that can't be undone anymore) where it doesn't require a type, but only stores it on types and warns otherwise. Jakub