On Tue, Apr 14, 2015 at 12:06:16PM -0400, Jason Merrill wrote: > With C++ templates and attribute ((aligned)), you can have TYPE_ALIGN and > TYPE_USER_ALIGN set on a type before you know its size, so layout_type and > kin need to respect them if they are already set. > > Tested x86_64-pc-linux-gnu. OK for trunk?
Wonder what will happen if finalize_type_size or fixup_attribute_variants is called on a type variant with TYPE_USER_ALIGN before it is called on the TYPE_MAIN_VARIANT; I'd guess that in that case all the variants including the main variant would be marked as TYPE_USER_ALIGN and might have incorrect TYPE_ALIGN. Perhaps they shouldn't propagate anything to other variants if user_align is set, or recurse (at least finalize_type_size) on the TYPE_MAIN_VARIANT if it is called on some other variant, as a way to propagate the layout to other variants? Otherwise the patch LGTM. Jakub